ABGR
ABGR

Reputation: 5235

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

I'm trying to fetch all Github public repositories with this GET request: https://api.github.com/repositories

This seems to returns the first 100 repositories. The documentation says,

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

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

My questions is:

  1. How should I use the Link header of the http-response in Javascript fetch Api to get the next batch of data

The above Api seems to return the first 100 APIs and the link in the Response Headersfor the same is something like this: link: <https://api.github.com/repositories?since=369>; rel="next", <https://api.github.com/repositories{?since}>; rel="first"

Upvotes: 1

Views: 5543

Answers (1)

amprew
amprew

Reputation: 261

Has this worked out for you? https://github.com/davidcelis/api-pagination/issues/92#issuecomment-360289942

You can access it via: Response.headers

response.headers.get('Link')

Upvotes: 0

Related Questions