Last active
January 24, 2017 15:48
-
-
Save carlosperate/956918488f4f9f4ed6926d86d4889c05 to your computer and use it in GitHub Desktop.
GH REST API
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>gh3</title> | |
</head> | |
<body> | |
<h1>Test</h1> | |
<script> | |
var arduRepos = null; | |
var getJSON = function(url, callback) { | |
var xhr = new XMLHttpRequest(); | |
xhr.open("get", url, true); | |
xhr.responseType = "json"; | |
xhr.onload = function() { | |
var status = xhr.status; | |
if (status == 200) { | |
callback(null, xhr.response); | |
} else { | |
callback(status); | |
} | |
}; | |
xhr.send(); | |
}; | |
getJSON("https://api.github.com/repos/carlosperate/ardublockly/releases", | |
function(err, data) { | |
if (err != null) { | |
alert("Something went wrong: " + err); | |
} else { | |
arduRepos = data; | |
console.log("latest: " + arduRepos[0].html_url + "\nAll:") | |
for (var i = 0; i < arduRepos.length; i++) { | |
console.log(arduRepos[i].html_url) | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment