-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
29 lines (22 loc) · 759 Bytes
/
script.js
File metadata and controls
29 lines (22 loc) · 759 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var response = null;
document.getElementsByTagName('button')[0].addEventListener('click', function(r){
getUser(document.getElementsByTagName('input')[0].value); });
function getUser(username){
// Fetch Github API
fetch('https://api.github.com/users/' + username)
// Promises
.then(function(r){
return r.json();
})
.then(function(j){
response = j;
profileData();
})
}
function profileData(){
document.getElementById("loader").style='display : none';
document.getElementById("avatar").src=response.avatar_url;
document.getElementById("username").innerText=response.login;
document.getElementById("location").innerText=response.location;
document.getElementById("bio").innerText=response.bio;
}