adapter.js
function(options, callback) {
    // Create a promise to defer to later
    var deferred = Bluebird.defer();

    // Fire the request
    request(this._buildRequestOptions(options), function(err, response, body) {
      // Handle Errors
      if (err) {
        // Usually a connection error (server unresponsive)
        err = new MuniError(err.message || 'Internal Server Error', err.code || 500);
      } else if (response.statusCode >= 400) {
        // Usually an intentional error from the server
        err = new MuniError(this._extractError(body), response.statusCode);
      }
      if (err) {
        debug.warn('Adapter Request Error with Code: %d', err.code);
        callback && callback(err);
        return deferred.reject(err);
      }

      // Handle Success
      debug.info('Adapter Request Sent with code: %d', response.statusCode);
      callback && callback(null, body);
      return deferred.resolve(body);
    }.bind(this));

    return deferred.promise;
  }
function(options, callback) {
    // Create a promise to defer to later
    var deferred = Bluebird.defer();

    // Fire the request
    request(this._buildRequestOptions(options), function(err, response, body) {
      // Handle Errors
      if (err) {
        // Usually a connection error (server unresponsive)
        err = new MuniError(err.message || 'Internal Server Error', err.code || 500);
      } else if (response.statusCode >= 400) {
        // Usually an intentional error from the server
        err = new MuniError(this._extractError(body), response.statusCode);
      }
      if (err) {
        debug.warn('Adapter Request Error with Code: %d', err.code);
        callback && callback(err);
        return deferred.reject(err);
      }

      // Handle Success
      debug.info('Adapter Request Sent with code: %d', response.statusCode);
      callback && callback(null, body);
      return deferred.resolve(body);
    }.bind(this));

    return deferred.promise;
  }
function ( options , callback ) { // Create a promise to defer to later var deferred = Bluebird . defer ( ) ; // Fire the request request ( this . _buildRequestOptions ( options ) , function ( err , response , body ) { // Handle Errors if ( err ) { // Usually a connection error (server unresponsive) err = new MuniError ( err . message || 'Internal Server Error' , err . code || 500 ) ; } else if ( response . statusCode >= 400 ) { // Usually an intentional error from the server err = new MuniError ( this . _extractError ( body ) , response . statusCode ) ; } if ( err ) { debug . warn ( 'Adapter Request Error with Code: %d' , err . code ) ; callback && callback ( err ) ; return deferred . reject ( err ) ; } // Handle Success debug . info ( 'Adapter Request Sent with code: %d' , response . statusCode ) ; callback && callback ( null , body ) ; return deferred . resolve ( body ) ; } . bind ( this ) ) ; return deferred . promise ; }
Send an HTTP Request with provided request options

@param {Object}   options
@param {Function} callback
@return {Promise}
Send an HTTP Request with provided request options