Created
December 29, 2013 21:05
-
-
Save learningjs/8174821 to your computer and use it in GitHub Desktop.
Code used to retrieve an user's watched repositories on Github. Always returns 30 results.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fetchJSONFile("https://api.github.com/users/" + userName + "/subscriptions", function(data){ | |
... | |
} | |
function fetchJSONFile(path, callback) { | |
var httpRequest = new XMLHttpRequest(); | |
httpRequest.onreadystatechange = function() { | |
if (httpRequest.readyState === 4) { | |
if (httpRequest.status === 200) { | |
var data = JSON.parse(httpRequest.responseText); | |
if (callback) callback(data); | |
} | |
} | |
}; | |
httpRequest.open('GET', path); | |
httpRequest.send(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment