-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
67 lines (34 loc) · 1.51 KB
/
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
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
// const API_URL = ("https://api.github.com/users/")
const form = document.querySelector("#form")
const userImgDiv = document.getElementById("imgdiv");
const userImg = document.getElementById("userImg");
const name = document.getElementById("name");
const following = document.getElementById("following");
const follower = document.getElementById("follower");
const repos = document.getElementById("repos");
const anchorTag = document.getElementById("anchorTag");
const container = document.getElementById("container");
// const btndiv = document.getElementById("btndiv");
form.addEventListener("submit", async (event) => {
event.preventDefault();
const value = event.target.children[0].value
// console.log(value)
const API_URL = `https://api.github.com/users/${value}`;
// console.log(API_URL)
try {
const response = await axios(API_URL);
console.log(response)
userImg.src = (response.data.avatar_url)
name.innerHTML = `<h1>${response.data.name}</h1>`
repos.innerHTML = ` ${response.data.public_repos}
<div>Repository</div>`
follower.innerHTML = `${response.data.followers}
<div>Follower</div>`
following.innerHTML = `${response.data.following}
<div>Following</div>`
anchorTag.href = `https://github.com/${value}`
} catch (error) {
// console.log(error.response.data.message);
}
// container.innerHTML = "";
})