fetch-collection
v1.0.1
Published
A minimal interface for fetching paginated resources from the web
Downloads
3
Readme
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
})