const mapLoop = async _ => {
console.log('Start')
const promises = books.forEach( async (book) => {
const ownerInfos = await User.find({_id: book.Owner})
return ownerInfos;
})
const ownerInformation = await Promise.all([promises])
console.log(ownerInformation)
console.log('End')
}
mapLoop();
The books variable consist of objects each with key value pair of nameBook, editionBook, _id, and Owner(which is an id). What I want to do here is find the owner of the book by the id stored in the value "Owner". However, the ownerInformation variable is printing undefined.