This repository was archived by the owner on Jul 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathtask9.html
94 lines (80 loc) · 2.12 KB
/
task9.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>API Fetching</title>
</head>
<style>
.container{
text-align: center;
}
img{border-radius: 20px;
height: 300px;
}
#bio{
font-size: large;
}
table{
font-size: large;
line-height: 30px;
text-align: left;
margin-left: auto;
margin-right: auto;
}
td{
width: 100px;
}
</style>
<body>
<div class="container">
<img id="avatar" alt="avatar not found">
<h2 id="name"></h2>
<p id="bio"></p>
<div >
<table>
<tr>
<td><span>Age:</span></td>
<td><span id="age"></span></td>
</tr>
<tr>
<td> <span>Gender:</span></td>
<td><span id="gender"></span></td>
</tr>
<tr>
<td><span>Email:</span></td>
<td><span id="email"></span></td>
</tr>
<tr>
<td><span>Loaction:</span></td>
<td> <span id="location"></span></td>
</tr>
<tr>
<td><span>Occupation:</span></td>
<td><span id="occupation"></span></td>
</tr>
<tr>
<td> <span>Hobbies:</span></td>
<td><span id="hobbies"></span></td>
</tr>
</table>
</div>
</div>
</body>
<script >
fetch('https://cc-bhu.github.io/web-development/assets/api/person.json')
.then(response => response.json())
.then(data => {
document.getElementById("avatar").src = data.avatar;
document.getElementById("name").innerHTML = data.name;
document.getElementById("bio").innerHTML = data.bio;
document.getElementById("age").innerHTML = data.age;
document.getElementById("gender").innerHTML = data.gender;
document.getElementById("email").innerHTML = data.email;
document.getElementById("location").innerHTML = data.location;
document.getElementById("occupation").innerHTML = data.occupation;
document.getElementById("hobbies").innerHTML = data.hobbies;
});
</script>
</html>