-1
I would like to popular this array with the Category object I get when I query findById
. But the variable loggedUserCategories
appears as an empty array in Sponse , however, I can visualize the console.log(category);
let loggedUserCategories = [];
categoriesId.forEach(async(id) => {
const category = await CategoryModel.findById(id);
loggedUserCategories.push(category)
console.log(category);
});
res.send(loggedUserCategories);