如何从octokit api中获得更多结果



我想使用octokit从github获取所有的repo。

所以我使用了throttlingpaginateRestrestEndpointMethods插件。

但无论我的搜索查询是什么,它都会返回1020个结果。

我怎样才能得到所有结果?

const searchQuery = "stars:>1+language:JavaScript";
import { Octokit } from "@octokit/core";
import { throttling } from "@octokit/plugin-throttling";
import { paginateRest } from "@octokit/plugin-paginate-rest";
import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods";
(async () => {
const MyOctokit = Octokit.plugin(
throttling,
paginateRest,
restEndpointMethods
);
const octokit = new MyOctokit({
auth: '..',
headers: {
Accept: "application/vnd.github.preview",
},
throttle: {
onRateLimit: (retryAfter, options, octokit) => {
octokit.log.warn(
`Request quota exhausted for request ${options.method} ${options.url}`
);
if (options.request.retryCount === 0) {
// only retries once
octokit.log.info(`Retrying after ${retryAfter} seconds!`);
return true;
}
},
onAbuseLimit: (retryAfter, options, octokit) => {
// does not retry, only logs a warning
octokit.log.warn(
`Abuse detected for request ${options.method} ${options.url}`
);
},
},
});
const results = await octokit.paginate(octokit.rest.search.repos, {
q: searchQuery,
});
console.log({ len: results.length }); // --> output 1020. should be much more.
})();

我不确定你是如何得到1020的,但文档指出"GitHub搜索API为每次搜索提供最多1000个结果">

这似乎是Github设置的一个硬性限制。

相关内容

  • 没有找到相关文章

最新更新