-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindexq3.html
83 lines (65 loc) · 3.06 KB
/
indexq3.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
<!DOCTYPE html>
<html>
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-9/reFTGAW83EW2RDu2S0VKaIzap3H66lZH81PoYlFhbGU+6BZp6G7niu735Sk7lN" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-w1Q4orYjBQndcko6MimVbzY0tgp4pWB4lZ7lr30WKz0vr/aWKhXdBNmNb5D92v7s" crossorigin="anonymous"></script>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<table class="table table-striped">
<thead>
<tr>
<th>Employee ID</th>
<th>Employee Name</th>
<th>Employee Salary</th>
<th>Employee Age</th>
<th>Profile Image</th>
</tr>
</thead>
<tbody id="tablebody">
</tbody>
</table>
</div>
</div>
<div class="row">
<div class="col-md-12 d-flex flex-row justify-content-center align-items-center">
<button class="btn btn-info m-3" onclick="fetchEmployee()">
Click for Data
</button>
</div>
</div>
</div>
<script>
const fetchEmployee = async() => {
const url = "http://dummy.restapiexample.com/api/v1/employees";
const res = await fetch(url);
const data = await res.json();
if (data.status == "success") {
const employeelist = [...data.data];
console.log(employeelist);
const tablebody = document.getElementById('tablebody');
employeelist.forEach(emp => {
const rowoftable = document.createElement('tr');
Object.keys(emp).forEach(item => {
const columnitem = document.createElement('td');
const textnode = document.createTextNode(emp[item]);
columnitem.appendChild(textnode);
rowoftable.appendChild(columnitem);
})
tablebody.appendChild(rowoftable);
})
}
}
</script>
</body>
</html>
</html>