request-as-bluebird

2.1.1 • Public • Published

request-as-bluebird

NPM version Build Status Coverage Status

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
    }
  );

license

MIT License

Package Sidebar

Install

npm i request-as-bluebird

Weekly Downloads

2

Version

2.1.1

License

MIT

Unpacked Size

15.6 kB

Total Files

8

Last publish

Collaborators

  • dentous