A bag-of-holding containing request utility functions.

npm install bagofrequest
1 downloads in the last day
23 downloads in the last week
86 downloads in the last month


Build Status Dependencies Status Published Version
npm Badge

Bag Of Request


Bag Of Request contains request utility functions.

bag.request uses, with:

  • proxy setting based on environment variables http_proxy, HTTP_PROXY, https_proxy, HTTPS_PROXY
  • excludes proxy if URL host is localhost or
  • thirty seconds default timeout
  • accepts self-signed SSL certificates
  • follow redirects by default
  • wildcard status code matching (e.g. 2xx, 50x)
  • custom handlers based on status code
  • default unexpected status code error with request body included in message
  • all bag.request defaults can be overriden by passing mikeal/request options
  • retry support with configurable delay

bag.proxy is a convenient function to retrieve proxy based on URL and environment value:

  • if URL uses http, then sets proxy to http_proxy or HTTP_PROXY
  • if URL uses https, then sets proxy to htps_proxy or HTTPS_PROXY or http_proxy or HTTP_PROXY
  • if URL does not have a protocol, then assume http protocol
  • if URL is not provided, then sets proxy to http_proxy or HTTP_PROXY or https_proxy or HTTPS_PROXY


npm install bagofrequest

or as a dependency in package.json file:

"dependencies": {
  "bagofrequest": "x.y.z"


var bag = require('bagofrequest');

bag.request('get', '', { timeout: 30000 }, function (err, result) {

var proxy = bag.proxy('');
npm loves you