-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
78 lines (72 loc) · 2.05 KB
/
index.html
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
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Profile Card</title>
<style>
body {
min-height: 100vh;
background-color: #00ffff;
display: flex;
justify-content: center;
align-items: center;
}
.card {
background-color: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 20px;
text-align: center;
max-width: 300px;
}
#name {
font-size: 24px;
font-weight: bold;
margin-bottom: 10px;
}
#bio {
font-size: 14px;
color: #888;
margin-bottom: 10px;
}
#followers {
font-size: 16px;
color: #888;
}
</style>
</head>
<body>
<div class="card">
<div id="image"></div>
<div id="name"></div>
<div id="bio"></div>
<div id="followers"></div>
</div>
<script>
const avatar = document.getElementById("image");
const name = document.getElementById("name");
const bio = document.getElementById("bio");
const followers = document.getElementById("followers");
const requestUrl = "https://github.com/gitapi/users/ajeetkumarrauniyar";
const xhr = new XMLHttpRequest();
xhr.open("GET", requestUrl);
xhr.onreadystatechange = function () {
// console.log(xhr.readyState);
if (xhr.readyState === 4 && xhr.status === 200) {
const data = JSON.parse(this.responseText);
console.log(data);
// Avatar
avatar.innerHTML = `<img src="${data.avatar_url}" alt="${data.name}'s avatar" style="width: 150px; height: 150px; border-radius: 50%; margin: 0 auto 20px;">`;
// Name
name.innerHTML = data.name;
// Bio
bio.innerHTML = data.bio;
// Followers
followers.innerHTML = `<b> Followers </b> ${data.followers}`;
}
};
xhr.send();
</script>
</body>
</html>