-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
34 lines (27 loc) · 807 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
34
const github = new Github;
const ui = new UI;
// Get input value
let searchField = document.querySelector('#searchField');
// searchFieldValue= searchField.value;
searchField.addEventListener('keyup', (e) => {
const userInput = e.target.value;
if(userInput != ""){
// Do the http fetch
github.getUser(userInput)
.then(data =>{
// console.log(data);
if (data.resData.message === 'Not Found'){
document.getElementById('profile').innerHTML=
`<div class="alert alert-danger">${userInput} is not found </div>`;
}else{
// Showing profile
ui.showProfile(data.resData);
ui.showRepos(data.reposData)
}
})
.catch(err => console.log(err));
// document.getElementById('profile').innerHTML= userName;
} else{
ui.clearProfile();
}
})