async function getResponse() {
let response = await fetch('https://dummyjson.com/products')
let jsonList = await response.json()
let list = document.querySelector('.products')
let key
let elements = jsonList.products
elements = elements.splice(0, 3)
for (key in elements) {
function getPictures() { //вывод ключей на картинки
for (let i = 0, length = elements.images[key].length; i < length; i++) {
return(elements.images[i]);
}
}
list.innerHTML +=
`<li class="item">
<h5 class="small_panel">${elements[key].title}</h5>
<div class="full_panel">
<img src="${elements[key].images[getPictures()]}" alt="${elements[key].description}"></img>
<p>brand: ${elements[key].brand}</p>
<p>category: ${elements[key].category}</p>
<p>${elements[key].description}</p>
<p>discount percentage: ${elements[key].discountPercentage} %</p>
<p>price: ${elements[key].price} usd</p>
<p>rating: ${elements[key].rating}</p>
<p>stock: ${elements[key].stock}</p>
</div>
</li>`
}
}
getResponse()
async function getResponse() {
let response = await fetch('https://dummyjson.com/products')
let jsonList = await response.json()
let list = document.querySelector('.products')
let key
let elements = jsonList.products
elements = elements.splice(0, 3)
for (key of elements) {
list.innerHTML +=
`<li class="item">
<h5 class="small_panel">${key.title}</h5>
<div class="full_panel">
<img src="${key.thumbnail}" alt="${key.description}"></img>
<p>brand: ${key.brand}</p>
<p>category: ${key.category}</p>
<p>${key.description}</p>
<p>discount percentage: ${key.discountPercentage} %</p>
<p>price: ${key.price} usd</p>
<p>rating: ${key.rating}</p>
<p>stock: ${key.stock}</p>
</div>
</li>`
}
}
getResponse()
async function getResponse() {
let response = await fetch('https://dummyjson.com/products')
let jsonList = await response.json()
let list = document.querySelector('.products')
let key
let elements = jsonList.products
elements = elements.splice(0, 3)
for (key in elements) {
function getPictures() { //вывод ключей на картинки
let images = ''
for (let i = 0, length = elements[key].images.length; i < length; i++) {
images += `<img src="${elements[key].images[i]}" alt="${elements[key].description}" />`
}
return images
}
list.innerHTML +=
`<li class="item">
<h5 class="small_panel">${elements[key].title}</h5>
<div class="full_panel">
${getPictures()}
<p>brand: ${elements[key].brand}</p>
<p>category: ${elements[key].category}</p>
<p>${elements[key].description}</p>
<p>discount percentage: ${elements[key].discountPercentage} %</p>
<p>price: ${elements[key].price} usd</p>
<p>rating: ${elements[key].rating}</p>
<p>stock: ${elements[key].stock}</p>
</div>
</li>`
}
}
getResponse()