My API call gets a response like this
{
products: {
product0: {
id: 'F103_SURFACELAPTOP_15',
quantity: 47,
description: 'Surface Laptop 15 Zoll'
},
product1: {
id: 'F101_MACBOOKPRO_13',
quantity: 10,
description: 'Macbook Pro 13 Zoll'
}
},
salesOrderId: '9000002080'
}
It can contain 1 - n products. I'm trying to print the response in a table
This is what I got which is working but it will just show the first product. However I need to loop through products and show every product
{value.map((item, i) =>
<tr key={i}>
<td>{i + 1}</td>
<td>{item.salesOrderId}</td>
<td>{item.products['product' + i].id}</td>
</tr>
)
This is how I tried to loop through it but with no success
{value.map((item, i) =>
<tr key={i}>
<td>{i + 1}</td>
<td>{item.salesOrderId}</td>
{item.products['product' + i].map((product, i) =>
<td key={i}> {product.i.id} </td>)}
<td>{item.products['product' + i].id}</td>
</tr>
)}