-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiExample.html
45 lines (31 loc) · 940 Bytes
/
apiExample.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
<!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>Cool Rooms</title>
</head>
<body>
<h1>Cool Rooms</h1>
<div id="rooms-container">
</div>
</body>
<script>
let roomContainer = document.getElementById('rooms-container')
let getRooms = async () => {
let response = await fetch('http://127.0.0.1:8000/api/rooms/')
let rooms = await response.json()
console.log("Rooms : ", rooms)
for (let i = 0; rooms.length > i; i++) {
let room = rooms[i];
console.log(room.name)
let row = `<div>
<h3>${room.name}</h3>
</div>`
roomContainer.innerHTML += row
}
}
getRooms()
</script>
</html>