-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
45 lines (43 loc) · 1.3 KB
/
Copy pathindex.html
File metadata and controls
45 lines (43 loc) · 1.3 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
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset='UTF-8'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Product Grid</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
.grid-container {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 10px;
}
.product-card {
border: 1px solid #ccc;
padding: 15px;
text-align: center;
background-color: #f9f9f9;
}
</style>
</head>
<body>
<h1>Product List</h1>
<div id='product-grid' class='grid-container'></div>
<script>
async function fetchProducts() {
const response = await fetch('/products');
const products = await response.json();
const gridContainer = document.getElementById('product-grid');
products.forEach(product => {
const card = document.createElement('div');
card.className = 'product-card';
card.innerHTML = `<h2>${product.name}</h2><p>Price: $${product.price}</p>`;
gridContainer.appendChild(card);
});
}
fetchProducts();
</script>
</body>
</html>