I'm working on a simple app where I want to list out a user's GitHub repos in a RecyclerView. I'm using this as my endpoint while building this.
The problem I'm facing is that the GitHub API returns only 30 repos in one go. To get more, I can append a per_page=100
(100 is the maximum) to my query string; But, what do we do about users with more than 100 repos?
The solution the API docs provide is to get the next;
url from the "Link" response header to make a second API call.
How does one go about this? Thanks!
The Response
class will let you access the headers. The GitHub client would have a method like:
@GET("/search/code")
Observable<Response<T>> getUser(...)
Inside onNext()
, you'd do something like:
@Override
public void onNext(Response<T> response) {
String next = response.headers().get("next");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With