I'm trying to get emails,firstname from a document and change a field in another one with my result, when i do a console.log(currentSenders) after my await i get all the data i need and when i try to push my result in the object, it push an empty array.
await cars.forEach(async (car) => {
await car.senders.slice(1).forEach(async (senderId) => {
currentSender = await Meteor.users.findOne({ _id: senderId })
currentSenders.push({
email: currentSender.emails[0].address,
firstname: currentSender.profile.name
})
console.log(currentSenders) // i get all the data i need
})
box.senders = currentSenders //i want to insert the array currentSender into senders
console.log(box) //the field box.senders is an empty array instead of being populated
})