I am not using CURL and only using jQuery, AJAX and JS for getting information from Github API. I am using a URL like this to get information about issues- https://api.github.com/repos/jquery/jquery/issues
But the result comes in multiple pages since Github API uses pagination feature. When using CURL we get to know about the header information in which the number of result pages are also shown but I am not using CURL and directly requesting data from above API url using jQuery and AJAX so I am unable to get the header information for above URL. I want to count the number of open and closed issues and open and closed PRs using the above URL for jquery/jquery repository and some other repositoris as well but since there is a lot of issues for some repositories, I am getting result in multiple pages.
I know about the "page" and "per_page" GET parameter that can be passed through the URL to get that result page and to display a number of results( e.g - 100) per page like this- https://api.github.com/repos/jquery/jquery/issues?page=5&per_page=100
I don't want to check the number of result pages manually. I want my script to get the number of result pages information automatically so that I can create a loop and iterate through all the pages to get information about all the issues.
e.g. if I get to know that the number of result pages are 8 then I can create a loop like this to get information about all the issues from all the result pages-
var number_of_pages=8;
var issues_information;
for(var nof=1; nof<=number_of_result_pages;nof++){
var URL='https://api.github.com/repos/jquery/jquery/issues?page='+nof+'&per_page=100';
$.getJSON(URL, function(json)){
issues_information=json;
}
}
Where "issues_information" will get JSON data that is fetched from Github API. But I am unable to get the count of result pages for a particular API call.
Can anybody tell me how to get number of result pages from Github API for a request? Please give an example code, URL format etc.