How to use the getNextPage function from @octokit/rest

Find comprehensive JavaScript @octokit/rest.getNextPage code examples handpicked from public code repositorys.

36
37
38
39
40
41
42
43
44
45
let done = false; // will be true when lastPR is seen in paginated results
let response = await method(methodProps);
let { data } = response;
data = prFilter(data, firstPR, lastPR, prPropsToGet);
while (octokit.hasNextPage(response) && !done ) {
  response = await octokit.getNextPage(response);
  let dataFiltered = prFilter(response.data, firstPR, lastPR, prPropsToGet);
  data = data.concat(dataFiltered);
}
return data;
fork icon9
star icon0
watch icon2

10
11
12
13
14
15
16
17
18
19
function getRemanding(response, resolve, reject) {
  if (!octokit.hasNextPage(response)) {
    return resolve(repos);
  }

  octokit.getNextPage(response).then((response) => {
    repos = repos.concat(parseRepos(response));
    getRemanding(response, resolve, reject);
  }).catch((err) => {
    return reject(err);
fork icon13
star icon34
watch icon74

30
31
32
33
34
35
36
37
38
39
function paginate(method) {
    return method({ org: organisation, type: 'public', per_page: 100 })
        .then(response => {
            let data = response.data
            while (octokit.hasNextPage(response)) {
                return octokit.getNextPage(response).then(response => data.concat(response.data))
            }
            return data
        })
}
fork icon2
star icon0
watch icon2

42
43
44
45
46
47
48
49
50
51
  type: 'all',
  per_page:100
})
var { data } = response;
while (octokit.hasNextPage(response)) {
  response = await octokit.getNextPage(response)
  data = data.concat(response.data)
}

return data    
fork icon0
star icon1
watch icon4