src/http/request.js
function request(options) {
  if (typeof options === 'string')
    options = { uri: options };

  options.buffer = true;

  return new Promise((resolve, reject) => {
    const req = new Request(options);

    req.on('error', err => reject(err));
    req.on('end', () => resolve(req));

    req.start();
    req.end();
  });
}
function request(options) {
  if (typeof options === 'string')
    options = { uri: options };

  options.buffer = true;

  return new Promise((resolve, reject) => {
    const req = new Request(options);

    req.on('error', err => reject(err));
    req.on('end', () => resolve(req));

    req.start();
    req.end();
  });
}
function request ( options ) { if ( typeof options === 'string' ) options = { uri : options } ; options . buffer = true ; return new Promise ( ( resolve , reject ) => { const req = new Request ( options ) ; req . on ( 'error' , err => reject ( err ) ) ; req . on ( 'end' , ( ) => resolve ( req ) ) ; req . start ( ) ; req . end ( ) ; } ) ; }
Make an HTTP request.
@alias module:http.request
@param {Object} options
@param {String} options.uri
@param {Object?} options.query
@param {Object?} options.body
@param {Object?} options.json
@param {Object?} options.form
@param {String?} options.type - One of `"json"`,
`"form"`, `"text"`, or `"bin"`.
@param {String?} options.agent - User agent string.
@param {Object?} [options.strictSSL=true] - Whether to accept bad certs.
@param {Object?} options.method - HTTP method.
@param {Object?} options.auth
@param {String?} options.auth.username
@param {String?} options.auth.password
@param {String?} options.expect - Type to expect (see options.type).
Error will be returned if the response is not of this type.
@param {Number?} options.limit - Byte limit on response.
@returns {Promise}
Make an HTTP request .