-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
33 lines (26 loc) · 872 Bytes
/
app.js
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
29
30
31
32
33
// Initialiaze Github class
const github = new Github;
// Initialiaze UI class
const ui = new UI;
// input for search user
const searchUser = document.getElementById("searchUser");
// check data that user enter in the input
searchUser.addEventListener("keyup", (e) => {
const userText = e.target.value;
if (userText !== "") {
// Make HTTP call
github.getUser(userText)
.then(data => {
if (data.profile.message === "Not Found") {
ui.showAlert("This user not found", "alert alert-danger");
} else {
ui.showProfile(data.profile);
ui.showRepos(data.repo);
}
})
} else {
// Clear profile data on page
clearProfile();
}
}
)