首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从octokit api中获得更多的结果?

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

Stack Overflow用户
提问于 2021-04-20 13:18:10
回答 1查看 491关注 0票数 0

我想使用八盒从github获得所有的回复。

所以我使用throttlingpaginateRestrestEndpointMethods插件。

但是,不管我的搜索查询是什么,返回1020的结果最多。

我怎么能得到所有的结果?

代码语言:javascript
复制
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.

})();
EN

回答 1

Stack Overflow用户

发布于 2021-04-20 13:35:12

我不知道如何得到1020,但是医生们声明“GitHub搜索API为每个搜索提供多达1,000个结果”。

这似乎是吉特布设定的一个硬性限制。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67179764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档