-
Notifications
You must be signed in to change notification settings - Fork 0
/
item.js
41 lines (36 loc) · 1.13 KB
/
item.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 body = document.querySelector('body')
const cardId = (new URLSearchParams(location.search).get('id'))
console.log(cardId)
fetch(`https://fakestoreapi.com/products/${cardId}`)
.then((res) => res.json())
.then((data) => {
console.log(data)
let container = document.createElement('div')
container.classList.add('container')
container.innerHTML = `
<div class="box1">
<img src="${data.image}"
alt="">
</div>
<div class="box2">
<div class="title">
<div class="heading">
<p>${data.title}</p>
</div>
<div class="description">
<p>${data.description}</p>
</div>
</div>
<div class="price">
<div class="pricing">
<p>price:${data.price}</p>
</div>
<div class="category">
<p>${data.category}</p>
</div>
</div>
</div>
`
body.appendChild(container)
})
.catch((err) => console.log(err))