Home > database >  GitHub Issue API only return 30 results
GitHub Issue API only return 30 results

Time:05-20

function loadComments(auth) {
    fetch("https://api.github.com/repos/{myusername}/{myreponame}/issues", {
            method: "GET",
            headers: {
                Authorization: "token "   auth,
            },
        })
        .then((res) => res.json())
        .then((res) => {
            console.log(res);
        });
}

when I try to run it, it only returns 30. I guess GitHub return results in portions when it is over 30. Any idea how I can get the rest of the results?

CodePudding user response:

Checkout the docs. It seems 30 results is the default results per page. You can set max to 100 results per page. https://docs.github.com/en/rest/issues/issues.

Note obviously this API works with a pagination system.

CodePudding user response:

30 Results are the default results per page. This is based on the Rate Limit API. To view you're authenticated limit you can request this :

const octokit = new Octokit({
  auth: 'personal-access-token'
})

await octokit.request('GET /rate_limit', {}) 

or you can read more about the rate limit api at : GitHub Rate Limit API

  • Related