Skip to content
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

Pass allItems and currentItems to _pagination.paginate() #1100

Merged
merged 28 commits into from Mar 9, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion readme.md
Expand Up @@ -685,7 +685,18 @@ Default: [`Link` header logic](source/index.ts)
The function takes three arguments: `response` (response object), `allItems` (array) and `currentItems` (array).
It should return an object representing Got options pointing to the next page. If there are no more pages, `false` should be returned.

For example, if you want to stop when the response contains less items than expected, you should use `(response, allItems, currentItems) => currentItems.length < response.request.options.searchParams.entriesPerPage ? false : { url: getNextLink(response, allItems, currentItems) }`.
For example, if you want to stop when the response contains less items than expected, you should use:
```
(response, allItems, currentItems) => {
Copy link
Owner

Choose a reason for hiding this comment

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

I would prefer the example to be fully runnable, meaning that it includes the import statement and got(…).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just extended the example.

if (currentItems.length < response.request.options.searchParams.entriesPerPage) {
szmarczak marked this conversation as resolved.
Show resolved Hide resolved
return false;
}

return {
url: getNextLink(response, allItems, currentItems)
};
}
```

###### \_pagination.filter

Expand Down