Skip to content

Commit

Permalink
docs(pagination): update pagination done() example (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefmikey committed Aug 13, 2022
1 parent 22f0e77 commit 26a6b5b
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions docs/src/pages/api/05_pagination.md
Expand Up @@ -37,12 +37,16 @@ octokit
To stop paginating early, you can call the `done()` function passed as 2nd argument to the response map function. Note that you still have to return the value you want to map the response to, otherwise the last response will be mapped to undefined.

```js
octokit.paginate("GET /organizations", (response, done) => {
if (response.data.find((issues) => issue.body.includes("something"))) {
done();
octokit.paginate(
"GET /repos/{owner}/{repo}/issues",
{ owner: "octokit", repo: "rest.js" },
(response, done) => {
if (response.data.find((issue) => issue.body.includes("something"))) {
done();
}
return response.data;
}
return response.data;
});
);
```

To paginate responses for one of the registered endpoint methods such as `octokit.rest.issues.listForRepo()` you can pass the method directly as first argument to `octokit.paginate`:
Expand Down

0 comments on commit 26a6b5b

Please sign in to comment.