-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoffice_chairs.html
46 lines (42 loc) · 1.76 KB
/
office_chairs.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>épipla</title>
<link rel="stylesheet" href="office_chairs.css">
</head>
<body>
<h1><center>Chairs</center></h1>
<div id="office">
<!-- Chair cards will be dynamically inserted here -->
</div>
<script>
const officeDiv = document.getElementById('office');
// Function to fetch chair data and images from Unsplash API
async function fetchChairData() {
try {
const response = await fetch('https://api.unsplash.com/search/photos?query=chair&client_id=MIuFsXm_pdrrWzlDJkgna1KcEfobWWCb8whlSip_2rg'); // Replace with your actual Unsplash API access key
const data = await response.json();
const chairs = data.results;
// Loop through the chair data and dynamically create cards
chairs.forEach((chair, index) => {
const chairCard = `
<div class="cards">
<img id="c${index + 1}" class="c" src="${chair.urls.small}" alt="${chair.alt_description}">
<div id="chair">${chair.alt_description ? chair.alt_description : 'Chair'}<hr>
<div class="price">₹${(1500 + index * 500)}</div>
</div>
</div>
`;
officeDiv.innerHTML += chairCard;
});
} catch (error) {
console.error('Error fetching chair data:', error);
}
}
// Call the function to fetch and display chair data
fetchChairData();
</script>
</body>
</html>