【问题标题】:How to get data from all pages in Git API with JavaScript如何使用 JavaScript 从 Git API 中的所有页面获取数据
【发布时间】:2020-11-18 04:50:42
【问题描述】:

我正在尝试获取组织内所有存储库的列表。 Git api 调用一次只返回 30 个 repos。我知道这可以更改为最多 100 个,但我的组织有更多的存储库。我有以下代码:

async function getRepos() {
    const url = "THEURL"
    const headers = {
        "Authorization": `Token temppp`
    }
    const response = await fetch(url, {
        "method": "GET",
        "headers": headers
    })
    const result = await response.json()
    console.log(result)
    
    const temp = []
    result.items.forEach(i => {
        temp.push(i.name);
    })
    console.log(temp)

}

在此,我试图获取所有 repos 的名称,但我一次只能做 30 个。有谁知道我怎样才能获得所有这些或浏览所有页面?

【问题讨论】:

    标签: javascript git api


    【解决方案1】:

    我在 python 中找到了解决方案,但我认为这对于制作大型程序并不有效。特别是因为稍后我将以类似的方式使用 git issues API,并且每个 repo 可能有超过 1000 个问题。 -> How to get data from all pages in Github API with Python?

    【讨论】:

      猜你喜欢
      • 2020-12-17
      • 2016-02-25
      • 1970-01-01
      • 2019-12-15
      • 1970-01-01
      • 2020-02-09
      • 1970-01-01
      • 2013-11-24
      • 1970-01-01
      相关资源
      最近更新 更多