nfp_sites/app/api/pagination.js

17 lines
370 B
JavaScript
Raw Normal View History

2019-09-14 19:03:38 +00:00
const parse = require('parse-link-header')
const { sendRequest } = require('./common')
exports.fetchPage = function(url) {
return sendRequest({
method: 'GET',
url: url,
}, true)
.then(result => {
return {
data: result.data,
links: parse(result.headers.link || ''),
total: Number(result.headers.pagination_total || '0'),
}
})
}