-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
33 lines (28 loc) · 832 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
// INIT GITHUB
const github = new Github;
// INIT UI
const ui = new UI;
// SEARCH INPUT
const searchUser = document.getElementById('searchUser');
// SEARCH INPUT EVENT LISTENER
searchUser.addEventListener('keyup', (e) => {
// GET INPUT TEXT
const userText = e.target.value;
if (userText !== '') {
// MAKE HTTP CALL
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);
}
})
} else {
// CLEAR PROFILE
ui.clearProfile();
}
})