Consume paginated APIs and return a giant array
This is a helper function which works best with the GitHub v3 api. I am more than happy to extend it to other APIs as needed.
$ npm install --save depaginate
const Octo = require('octokat')
const octo = new Octo()
const depaginate = require('depaginate');
function test () {
var inputArray = []
return depaginate(inputArray, function (opts) {
return octo.repos(opts.org, opts.repo).branches.fetch({
per_page: 100,
page: opts.page
})
}, {
org: opts.org,
repo: repo.name
})
}
Type: array
This is the array that will be returned. It needs to be set outside of the callFx, hence passing it in.
Type: function
This is the function to call the API again.
Type: object
This is specifically for page
, but also for any options required by the call function.
MIT © Richard Littauer