从静态网页访问 github

Accessing github from static webpage

我正在尝试编写一个静态网页,它将提取 github 存储库中的所有当前拉取请求并显示它们。我想使用 octokit.js 但那是为了 node.js。有没有一种直接的方法可以通过静态网页对 github 存储库进行经过身份验证的调用?

GitHub的API很开放。你可以fetch('https://api.github.com/repos/:user/:repo/pulls')https://developer.github.com/v3/pulls/#list-pull-requests

请注意,未经身份验证的请求是有限制的,但您不必担心这一点。

运行 以下示例可查看针对 Node.js 核心的当前拉取请求列表。

fetch('https://api.github.com/repos/nodejs/node/pulls')
  .then((r) => r.json())
  .then((pulls) => {
    pulls
      .map((p) => `[${p.number}] ${p.title} (${p.html_url})`)
      .forEach((s) => console.log(s));
  });