I want to get the allItems variable outside the function, but I just can get an empty array. The first console.log shows the array I wanted, but the second it's just [].
var allItems = [];    
orderPads.forEach(async  element => {
        
        element.orders_fk.forEach(async elem => {
            
            let itemsArray = await OrderedItem.find({ order_fk: elem });
            
            
            itemsArray.forEach(async e => {
                 
                let temp = e.toObject();
                const mesa = await Table.findById(element.mesa);
                temp.mesa = mesa.name;
                
                allItems.push(temp)
                console.log(allItems)
                
            })
        })
    });
console.log(allItems)
I've already looked for answers online, but nothing seems to work in this case. Thank you for the help!
 
    