Skip to content

Instantly share code, notes, and snippets.

@esin
Created May 8, 2020 15:51
Show Gist options
  • Save esin/89dd3eed4ec9eb29a4ed15ff25d088ee to your computer and use it in GitHub Desktop.
Save esin/89dd3eed4ec9eb29a4ed15ff25d088ee to your computer and use it in GitHub Desktop.
Get GitHub forks
var xhr = new XMLHttpRequest();
xhr.responseType = "json";
xhr.open('GET', "https://api.github.com/repos/iBotPeaches/Apktool/forks", true);
xhr.send();
xhr.onreadystatechange = processRequest;
function processRequest(e) {
if (xhr.readyState == 4 && xhr.status == 200) {
var forks = xhr.response;
forks.forEach(function(fork){
var commitsUrl = fork.commits_url;
if (commitsUrl.indexOf('{') > 0) {
commitsUrl = commitsUrl.substring(0, commitsUrl.indexOf('{'));
}
var xhrFork = new XMLHttpRequest();
xhrFork.responseType = "json";
xhrFork.open('GET', commitsUrl, true);
xhrFork.send();
xhrFork.onreadystatechange = function(e){
if (xhrFork.readyState == 4 && xhrFork.status == 200) {
var commits = xhrFork.response;
console.log(commitsUrl, commits[0].commit.committer.date);
}
};
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment