-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
40 lines (28 loc) · 1.24 KB
/
app.js
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
let mainContainer = document.getElementById('mainContainer')
fetch('https://fakestoreapi.com/products')
.then((res) => res.json())
.then((data) => {
console.log(data)
data.forEach(item => {
console.log(item.id)
let col = document.createElement('div')
let anchor = document.createElement('a')
anchor.href = `./item.html?id=${item.id}`
anchor.classList.add('anchor')
col.classList.add('col')
anchor.innerHTML = `
<div class="card shadow-sm" style="border: 10px solid #93C54B; height:600px">
<img src="${item.image}"
class="bd-placeholder-img card-img-top" width="100%" height="400" alt="">
<div class="card-body" style="background-color: #93C54B;">
<h3 class='text-center'>${item.title}</h3>
<p class="card-text"></p>
<div class="d-flex justify-content-between" style='position:absolute;bottom:10px;'>
</div>
</div>
</div>
`
col.appendChild(anchor)
mainContainer.appendChild(col)
})
})