I make a async function to get offers, and add to array with another array. But the offers array are looking empty in console, but when I click shows the itens.
The products are comming that's isn't the problem. The problem is that I can't add the arrayOffers to itemsArray.
OBS: the forEach is from p-interation lib.
this is my code.
useEffect(() => {
if (auth && auth._id) {
const fetchUserVisitedProducts = async (id) => {
const user = await getPublicUserRequest(id);
let array = [];
forEach(user.offers_visited, async (id) => {
const offers = await getOfferRequest(id)
array.push(offers)
});
const arrayOffers = array;
console.log(arrayOffers)
const itemsArray = [ ...user.barbadas_visited, ...arrayOffers]
console.log(itemsArray)
}
fetchUserVisitedProducts(auth._id)
}
},[auth])
In the image, I see one array with 4 objects, but looks empty. And another array that is correct.

forEach()call before logging so it's empty when first logged, but Chrome logs live arrays, so it gets updated in the view later.Array is looking empty, but have 4 objectsThe reason for this is answered here: console.log of element.children shows 0 length but has three entries when expanded later