Skip to content

Instantly share code, notes, and snippets.

@ishu3101
Created June 24, 2017 09:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ishu3101/bfaeaf9f553ca99ad35c68a7f9b87d00 to your computer and use it in GitHub Desktop.
Save ishu3101/bfaeaf9f553ca99ad35c68a7f9b87d00 to your computer and use it in GitHub Desktop.
List all the users github repository using javascript only
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Github Repository</title>
</head>
<body>
<script>
var username = "ishu3101";
var url = "https://api.github.com/users/" + username + "/repos";
var xhr = new XMLHttpRequest();
xhr.open("GET",url,true);
xhr.onload = function(){
var jsonResponse = this.responseText;
var data = JSON.parse(jsonResponse);
//console.log(data);
for (repo in data){
var repo = data[repo];
console.log(repo.name + " - " + repo.description);
}
}
xhr.onerror = function(){
console.log("http request error");
}
xhr.send();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment