Skip to content

Commit

Permalink
Fixing #82
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalrymple committed May 10, 2018
1 parent c34a9ae commit 55c34f2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/infrastructure/RequestHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ async function getPaginated(service, endpoint, options = {}) {
const response = await service.requester.get(requestOptions);
const links = LinkParser(response.headers.link);
const page = response.headers['x-page'];
const limit = options.maxPages ? page < options.maxPages : true;
let more = [];
const underMaxPageLimit = options.maxPages ? page < options.maxPages : true;

if (page && limit && links.next) {
more = await getPaginated(service, links.next.url.replace(service.url, ''), options);
// If not looking for a singular page and still under the max pages limit AND their is a next page, paginate
if (!options.page && underMaxPageLimit && links.next) {
const more = await getPaginated(service, links.next.url.replace(service.url, ''), options);

return [...response.body, ...more];
}
Expand Down

0 comments on commit 55c34f2

Please sign in to comment.