fetch-collection

1.0.1 • Public • Published

fetch-collection

A wrapper for rest-collection-stream that makes fetching paginated JSON easier and handles query parameters.

Install

yarn add fetch-collection

Usage

var collection = require('fetch-collection')
 
collection('https://api.github.com/search/repositories', {
  q: 'language:javascript',
  sort: 'stars',
  order: 'desc'
}).fetch('json', {
  data: (response, body) => body.items, // return an array of data
  next: (response, body) => body.links.next, // return a string (URL) or an object (params)
}).on('data', item => {
  // do something with item
})
 

Readme

Keywords

none

Package Sidebar

Install

npm i fetch-collection

Weekly Downloads

1

Version

1.0.1

License

ISC

Last publish

Collaborators

  • aeaton