Hello dear community,
I want to store the result of an async map() function that walk through an array of ids and use the Todo.findById(todo.id) method to retrieve the actual todo object, here's my code :
const todoIds = ["6325a0fa4d1b728890d90d98", "6325a0fa4d1b728890d90d97", "6325a0fa4d1b728890d90d96"];
const tasks = await todoIds.map(async (id) => {
const task = await Todo.findById(id);
return task;
});
But here's the console.log(tasks) :
[ Promise { <pending> }, Promise { <pending> }, Promise { <pending> } ]