-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[BUG]: auto pagination is not working for listPackagesForOrganization #2400
Comments
Are you using the plugin-paginate-rest package when doing so? |
I didn't know you needed that, I assume that comes when you install the full octokit module? eg. // npm install octokit
const { Octokit } = require('octokit');
const octokit = new Octokit({ auth: "<token>" });
const packages = await octokit.paginate(octokit.rest.packages.listPackagesForOrganization, {
org: '<org>',
package_type: 'npm',
}); But even after switching to use the plugin like so, it still is only return the default length (30). My workaround right now is to do the pagination manually via loop, but I assume the paginate helper so suppose to help with that. // npm install @octokit/core
// npm install @octokit/plugin-paginate-rest
const { Octokit } = require('@octokit/core');
const { paginateRest } = require('@octokit/plugin-paginate-rest');
const MyOctokit = Octokit.plugin(paginateRest);
const octokit = new MyOctokit({ auth: "<token>" });
const packages = await octokit.paginate('GET /orgs/{org}/packages', {
org: '<org>',
package_type: 'npm',
});
console.log(packages.length) // returns first 30, even though I expect it to return all As I noted above, the paginate helper does seem to work with the octokit.rest.repos.listForOrg endpoint just not the octokit.rest.packages.listPackagesForOrganization endpoint. |
I don't mean to intrude here, but I faced the same issue and tried it with the github cli and figured out the link headers are not being sent by Github servers. There is already a created issue https://github.com/orgs/community/discussions/128552. Please give it an upvote if it matches your description. |
What happened?
Trying to use
octokit.paginate
withoctokit.rest.packages.listPackagesForOrganization
to return all results.Example:
I have provided personal access token with follow scope:
read:packages
,repo
,user:email
Expect: Return all packages for given organization (more than 30 results)
Actual: Only returns the first page results limited to the default page size of 30
octokit.rest.repos.listForOrg
seems to work fineVersions
Octokit.js v2.0.14, Node v16.18.1
Relevant log output
No response
Code of Conduct
The text was updated successfully, but these errors were encountered: