-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
23 lines (19 loc) · 747 Bytes
/
Copy pathapp.js
File metadata and controls
23 lines (19 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function pageLoad() {
document.getElementById("btnGetGitHubName").addEventListener(
'click', getGitHubUserDetails
);
}
function getGitHubUserDetails () {
console.log("in getGitHubUserDetails");
const respGitHub = axios.get("https://api.github.com/users/" + document.getElementById("inputName").value);
console.log(respGitHub);
respGitHub.then(function(rtnData) {
document.getElementById("imgGitHubImage").src = rtnData.data.avatar_url;
document.getElementById("gitHubName").innerText = rtnData.data.name;
});
respGitHub.catch( (err) => {
document.getElementById("gitHubName").innerText = "An error has occured: " +
err.response.status;
})
}
window.onload = pageLoad;