request-all

2.0.2 • Public • Published

request-all npmjs.com The MIT License

Performs a multiple requests and data from all pages are concatenated together and buffered until the last page of data has been retrieved. Use it as standalone module or as wrapper for simple-get - just pass simple-get.

code climate standard code style travis build status coverage status dependency status

ProTips

  • use v1.x if you want to use/pass simple-get@1.x, npm tagged as latest-1
  • use v2.x if you want to use/pass simple-get@2.x, npm tagged as latest

Install

npm i request-all --save

Usage

For more use-cases see the tests

const requestAll = require('request-all')

requestAll

Perform multiple requests until the last page of data has been retrieved.

Params

  • url {Function|String|Object}: the simple-get function, url, or object
  • [opts] {Object}: optional options, url and opts are merged if both are objects
  • <cb> {Function}: callbackfunction, you can pass it as second argument
  • returns {Function}: the simple-get function, only if given as first argument, undefined otherwise

Example

const requestAll = require('request-all')
requestAll('https://api.github.com/users/tunnckoCore/repos', (err, data) => {
  if (err) return console.error(err)
  console.log(data.length) // => 200+ repos
})

Usage as wrapper

If you pass simple-get to it or any request library that have .concat method, it just returns it and adds .requestAll method.

Example

const simpleGet = require('request-all')(require('simple-get'))
 
simpleGet.requestAll('http://httpbin.org/ip', {json: false}, (err, buf) => {
  if (err) return console.error(err)
  console.log(buf.toString()) // => '{"origin": "33.125.89.244"}'
})

Related

Contributing

Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
But before doing anything, please read the CONTRIBUTING.md guidelines.

Charlike Make Reagent new message to charlike freenode #charlike

tunnckoCore.tk keybase tunnckoCore tunnckoCore npm tunnckoCore twitter tunnckoCore github

Package Sidebar

Install

npm i request-all

Weekly Downloads

7

Version

2.0.2

License

MIT

Last publish

Collaborators

  • vanchoy
  • tunnckocore