I'm facing what seems to be a minor issue that I can't seem to resolve. The response body I have looks like this:
{
"sizes": [
{
"43": 35
},
{
"42": 20
},
{
"38": 10
}
]
}
with the keys representing shoe sizes and the values indicating the quantity for each size. How can I access these sizes effectively? Currently, my approach is as follows:
const sizesArray = response.data.sizes
const arr = Object.values(msizes);
console.log('arr', arr);
arr.map((i,a) => {
console.log('i',i);
console.log('a',a);
})
However, 'i' turns out to be another object {43: 35}
and 'a' is simply the index. I want to somehow assign the key to a parameter called 'sizes' and the value to a parameter called 'quantity'.
https://codesandbox.io/s/confident-ishizaka-rqjvbv?fontsize=14&hidenavigation=1&theme=dark