Aquí está mi código:
// get "foods" array from Firebase const foods = querySnapshot.docs.map((doc) => ({ ...doc.data() })); // loop in "foods" array and recover food's price const fetchPrices = async () => { for (const food of foods) { const response = await fetch(`${api}/${food.id}`); if (!response.ok) { // throw error } const result = await response.json() food.totalPrice = food.quantity * result.market_data.current_price } } // run function fetchPrices() // this console.log show me initial values, without totalPrice key console.log('foods : ', foods); Supongo que console.log() se ejecuta antes de la función async/await, pero no sé cómo agregar este valor en mi matriz inicial (u otra).
¿Cuál sería la forma de agregar la clave/valor totalPrice a cada elemento de la matriz "alimentos"?