From 26a6b5b05c76b8a92708e5c9eec77f583451bf08 Mon Sep 17 00:00:00 2001 From: Mikl Wolfe Date: Fri, 12 Aug 2022 18:03:42 -0600 Subject: [PATCH] docs(pagination): update pagination `done()` example (#186) --- docs/src/pages/api/05_pagination.md | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/docs/src/pages/api/05_pagination.md b/docs/src/pages/api/05_pagination.md index ed6b09b1..e1457572 100644 --- a/docs/src/pages/api/05_pagination.md +++ b/docs/src/pages/api/05_pagination.md @@ -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`: