-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
31 lines (29 loc) · 909 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
//Init Github variable from github class
const github = new Github;
//Init UI variable from UI class
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
console.log(data);
console.log(data.profile);
ui.showProfile(data.profile);
}
})
} else {
//Clear profile
ui.clearProfile();
}
});