Repository navigation
Expand file tree
/
Copy pathGithub.js
More file actions
69 lines (48 loc) · 1.5 KB
/
Copy pathGithub.js
File metadata and controls
69 lines (48 loc) · 1.5 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
let main = document.querySelector("main");
let box1 = document.querySelector(".box1");
let imagine = document.querySelector(".imagine");
let input = document.querySelector("#search");
let title = document.querySelector(".title");
let idd = document.querySelector(".idd");
let git = document.querySelector(".git")
let span = document.querySelector(".span")
let sp = document.querySelector(".sp")
let ip = document.querySelector(".ip")
let Repo = document.querySelector(".Repo")
let box2 = document.querySelector("maincontent")
let searcher = document.querySelector("#glow")
input.addEventListener("click", fd)
searcher.addEventListener('keydown', press);
function press(event) {
if (event.key == "Enter") {
fd();
return;
}
}
searcher.addEventListener("input", () => {
if (searcher.value.trim() !== "") {
fd();
return;
}
});
async function fd() {
let username = searcher.value;
const url = `https://api.github.com/users/${username}`;
try {
let response = await fetch(url);
let data = await response.json();
console.log(data);
imagine.src = data.avatar_url;
title.innerHTML = data.login;
idd.innerHTML = data.node_id;
git.href = data.html_url;
git.innerHTML = data.html_url;
span.innerHTML = `Followers = ${data.followers}`;
sp.innerHTML = `| Following = ${data.following}`;
ip.innerHTML = `| ID = ${data.id}`;
Repo.innerHTML = `| Repositries = ${data.public_repos}`;
} catch (error) {
console.log(error);
console.log("bye");
}
}