-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPIPractice.html
More file actions
61 lines (50 loc) · 1.58 KB
/
APIPractice.html
File metadata and controls
61 lines (50 loc) · 1.58 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
<!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</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Ubuntu&display=swap" rel="stylesheet">
<style>
body {
font-family: 'Ubuntu', sans-serif;
}
#APIDataTable {
display: flex;
flex-wrap: wrap;
}
.bxInit {
height: 5rem;
width: 10rem;
background-color: #e6e4e4;
border-radius: 5px;
margin: 5px;
display: flex;
justify-content: center;
align-items: center;
font-size: 20px;
font-weight: bold;
}
</style>
</head>
<body>
<div id="APIDataTable">
</div>
<script>
const fetchCall = fetch('https://jsonplaceholder.typicode.com/comments');
const responce = fetchCall.then((res) => res.json()).catch((err) => console.log(err));
responce.then((res) => {
document.getElementById('APIDataTable').innerHTML = renderTableData(res);
})
const renderTableData = (list) => {
return list.map(
(element) =>
`<div class="bxInit">P:${element.postId} || Id:${element.id}</div>`
).join("");
}
</script>
</body>
</html>