My code:
const getStats = async (projects) => {
return projects.map(async (project) => {
const count = await db.ping.count({
where: { projectId: project.id },
})
console.log("Result is: " + count)
return count
})
}
The return value (there are two different projects, so two elements are correct):
[ Promise { <pending> }, Promise { <pending> } ]
If I understand that correctly, my outer promise when I call the function gets resolved correctly. Hence the array itself is not wrapped in a Promise. However, my two values still seem to be wrapped in a promise. The weird thing is that the console.log
calls output the correct count number for each project, without any Promises:
Result is: 8
Result is: 1
Can anyone help me out here?