I got the following json:
{
"nodes": [
{
"variants": {
"nodes": [
{
"id": "98765",
"title": "Gold",
"priceV2": {
"amount": "95.0",
"currencyCode": "EUR"
}
},
{
"id": "65543",
"title": "Silver",
"priceV2": {
"amount": "95.0",
"currencyCode": "EUR"
}
},
{
"id": "12345",
"title": "Gold",
"priceV2": {
"amount": "95.0",
"currencyCode": "SEK"
}
},
{
"id": "11122",
"title": "Black",
"priceV2": {
"amount": "95.0",
"currencyCode": "EUR"
}
}
]
}
}
]
}
I have a hard time using .map or .forEach because .map just re-creates the array all the time.
How can I render the id, title, pricev2 part inside JSX?
Eg {product.title}, {product.priceV2}
I tried
products.map((product) => {
return product.nodes
})
Then what?
nodesarray, or if the only property of the element will bevariants. You could tryproducts.nodes[0].variants.nodes.map(...)if not.