2.1.1 • Published 5 years ago
request-as-bluebird v2.1.1
request-as-bluebird
promise wrapper for the npm request package
wraps the npm request package, in a bluebird promise, resolving with an object containing the response and body or rejecting with an Error
; also allows you to turn on debugging using the npm request-debug package.
table of contents
installation
npm install request-as-bluebird
usage
getRequestAsBluebird( user_options, debug )
@param {string|Object} user_options
@param {boolean} [debug]
@returns {Promise}
the request package documentation details available user options. you may also want to consider using the generic-request-options package to create the initial user options object.
default
var getRequestAsBluebird = require( 'request-as-bluebird' );
getRequestAsBluebird( 'https://www.google.com' )
.then(
/**
* @param {Object} result
* @param {IncomingMessage} result.response
* @param {string} result.body
*/
function( result ) {
// handle resolve
}
)
.catch(
/**
* @param {Error} err
*/
function( err ) {
// handle reject
}
);
with request-debug
var getRequestAsBluebird = require( 'request-as-bluebird' );
getRequestAsBluebird( 'https://www.google.com', true )
.then(
/**
* @param {Object} result
* @param {IncomingMessage} result.response
* @param {string} result.body
*/
function( result ) {
// handle resolve
}
)
.catch(
/**
* @param {Error} err
*/
function( err ) {
// handle reject
}
);