I don't understand why it returns each fruit with the same size. It's like it returns only the fruit size of the first fruit / first fetch result. I mean allFruits has always the same size, thats not correct. And make an await in the object element like { name: await getFruitName(f.1)} does not work. Maybe the function should be called in another place?
const food = await fetchFood();
food.entries.map(await fruits)
var allFruits = {}
async function fruits(f) {
allFruits=
{
name: getFruitName(f.1)
}
let fruitSize = await FetchFruitsSize(f.2)
allFruits.size = fruitSize.data[0].sizes[1]
}
return allFruits
If somebody has an example how to change the object value for each array element with calling a function that is calling a fetch, I would be very greateful