-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
28 lines (26 loc) · 854 Bytes
/
script.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
let search = document.querySelector(".search");
let inp = document.querySelector("#userName");
let btn = document.querySelector("#searchBtn");
let profile = document.querySelector(".profile");
let info = new Informations();
btn.addEventListener("click", (e) => {
let userName = inp.value;
// Fetch API
if (userName != "") {
Promise.all([
fetch(`https://api.github.com/users/${userName}`).then(resp => resp.json()),
fetch(`https://api.github.com/users/${userName}/repos`).then(resp => resp.json())
]).then((data) => {
if (data[0].message == "Not Found") {
info.notFound("User Not Found");
} else {
info.showInfo(data[0]);
info.sliderRepo(data[0],data[1]);
}
});
} else {
info.clearProfile("Enter UserName!!!");
}
inp.value = '';
e.preventDefault();
});