-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (26 loc) · 760 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
const github = new Github();
const ui = new UI();
const search = document.getElementById("btn");
search.addEventListener("click", (e) => {
e.preventDefault();
const searchUser = document.getElementById("searchUser");
const userText = searchUser.value;
if (userText !== "") {
github
.getUser(userText)
.then((data) => {
if (data.profile.message === "Not Found") {
//show alert
ui.showAlert("User not found", "alert alert-danger");
} else {
//show profile
ui.showProfile(data.profile);
ui.showRepos(data.repos);
}
})
.catch((err) => console.log(err));
} else {
//clear profile
ui.clearProfile();
}
});