I'm trying to get json data from this structure:
"items": {
"adidas": [
{
"name": "STAN SMITH PRIMEGREEN",
"price": 84.9,
"image": "https://m/dww/data/products/stan-smith-primegreen.png",
"availability": [
{
"size": 36,
"quantity": 5
},
{
"size": 37,
"quantity": 7
},
{
"size": 44,
"quantity": 9
}
]
}
I'm able to get this data using the below code is working:
const $showData = $("#show-data");
$.getJSON("data.json", (data) => {
const markup = data.items.adidas.map((item) => `
<!--Product-->
<img src="${item.image}" alt="shoes image" class="u-max-full-width">
<h3 class="bold title">${item.name}</h3>
<h2 class="price">${item.price}</h2>
<p class="subtitle">${item.brand}</p>
<p class="desc">${item.description}</p>
`)
.join("");
const list = $("<p />").html(markup);
$showData.html(list);
But when i tried to get availability array (size and quantity).
data.items.adidas.availability.map and i got this error:
Cannot read properties of undefined (reading 'map')