Blame view

node_modules/superagent/lib/request.js 739 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  // The node and browser modules expose versions of this with the
  // appropriate constructor function bound as first argument
  /**
   * Issue a request:
   *
   * Examples:
   *
   *    request('GET', '/users').end(callback)
   *    request('/users').end(callback)
   *    request('/users', callback)
   *
   * @param {String} method
   * @param {String|Function} url or callback
   * @return {Request}
   * @api public
   */
  
  function request(RequestConstructor, method, url) {
    // callback
    if ('function' == typeof url) {
      return new RequestConstructor('GET', method).end(url);
    }
  
    // url first
    if (2 == arguments.length) {
      return new RequestConstructor('GET', method);
    }
  
    return new RequestConstructor(method, url);
  }
  
  module.exports = request;