Created
June 24, 2017 09:01
-
-
Save ishu3101/bfaeaf9f553ca99ad35c68a7f9b87d00 to your computer and use it in GitHub Desktop.
List all the users github repository using javascript only
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
<!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