Skip to content

#569 tamer1an fix for get all pages in _requestAllPages #575

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions lib/Requestable.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,20 @@ class Requestable {
results.push(...thisGroup);

const nextUrl = getNextPage(response.headers.link);
if (nextUrl && !(options && typeof options.page !== 'number')) {
log(`getting next page: ${nextUrl}`);
return this._requestAllPages(nextUrl, options, cb, results);
if(nextUrl) {
if (!options) {
options = {};
}
options.page = parseInt(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's possible for options to be undefined. Please handle this prior to setting page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok will do that

nextUrl.match(/(page=[0-9]*)/g)
.shift()
.split('=')
.pop()
);
if (!(options && typeof options.page !== 'number')) {
log(`getting next page: ${nextUrl}`);
return this._requestAllPages(nextUrl, options, cb, results);
}
}

if (cb) {
Expand Down