forked from divanov11/StudyBud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiexample.html
42 lines (29 loc) · 828 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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>Cool Rooms</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
</head>
<body>
<h1>Cools Rooms</h1>
<div id="rooms-container">
</div>
</body>
<script>
let roomsContainer = document.getElementById('rooms-container')
let getRooms = async () => {
let response = await fetch('http://127.0.0.1:8000/api/rooms/')
let rooms = await response.json()
for (let i = 0; rooms.length > i; i++) {
let room = rooms[i]
let row = `<div>
<h3>${room.name}</h3>
</div>`
roomsContainer.innerHTML += row
}
}
getRooms()
</script>
</html>