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
7 changes: 4 additions & 3 deletions readme.md
Expand Up @@ -680,11 +680,12 @@ A function that transform [`Response`](#response) into an array of items. This i
###### \_pagination.paginate

Type: `Function`\
Default: `(response, allItems, currentItems) => getLinkFromHeaders(response)` (find details [here](source/index.ts))
Default: [`Link` header logic](source/index.ts)

A function that returns an object representing Got options pointing to the next page. If there are no more pages, `false` should be returned.
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 that expected, you should use `(response, allItems, currentItems) => currentItems.length < LIMIT ? 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) => currentItems.length < response.request.options.searchParams.entriesPerPage ? false : { url: getNextLink(response, allItems, currentItems) }`.
jaulz marked this conversation as resolved.
Show resolved Hide resolved

###### \_pagination.filter

Expand Down