-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
47 lines (46 loc) · 1.29 KB
/
index.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Vehicles - All Vehicles</title>
<style>
body{
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
.brands-list{
list-style-type: none;
}
.brands-list li{
background:rgba(100, 100, 120, 0.5);
padding: 5px 15px;
margin-bottom: 10px;
}
.brands-list li a{
text-decoration: none;
font-size: 1.1rem;
}
</style>
</head>
<body>
<h1>Welcome to the brands</h1>
<div class="container">
<ul class="brands-list">
</ul>
</div>
<script>
const port = window.location.host.split(":")[1];
const endpoint = `http://localhost:${port}/vehicles`;
generateBrands = async () => {
const brands = await fetch(endpoint).then(d => d.json());
let html = "";
brands.forEach(brand => {
html += `<li><a>${brand.name}</a></li>`;
});
const brandsList = document.querySelector(".brands-list");
brandsList.innerHTML = html;
}
generateBrands();
</script>
</body>
</html>