如何使用 Link Header 的 HTTP 响应从 github API 中获取下一批数据?

How to use Link Header of HTTP reponse to fetch next batch of data from github API?

我正在尝试使用此 GET 请求获取所有 Github public 存储库:https://api.github.com/repositories

这似乎是 return 的第一个 100 存储库。文档说,

It's important to form calls with Link header values instead of constructing your own URLs.

https://developer.github.com/v3/#link-header

我的问题是:

  1. JavascriptfetchApi中http-response的Linkheader如何获取下一批数据

上面的Api好像return前100个API和Response Headers中的link一样是这样的: link: <https://api.github.com/repositories?since=369>; rel="next", <https://api.github.com/repositories{?since}>; rel="first"

这对你有用吗? https://github.com/davidcelis/api-pagination/issues/92#issuecomment-360289942

您可以通过以下方式访问它:Response.headers

response.headers.get('Link')