nodejs async await on for loop

I want create a for loop and make some async process on this for loop. For each step on loop I want to push item to an array. But I cannot do this.

My code snipped like that:

 var workspace = []
 for await (const workspaceId of workspaceIds) {
            const workspace = WorkspaceRepository.find({id : workspaceId})

But, output like that:

[ Promise { <pending> }, Promise { <pending> } ]
[ Promise { <pending> }, Promise { <pending> } ]

How can I do this? I tried to some solutions but any solution didn't work.

Read more here:

Content Attribution

This content was originally published by akasaa at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: