The array.map(x => await act(x)) Promise Headache

todo: these are just some notes...

array.map(async (x) => await act(x)) returns an array of resolved promises, not an array of the result of act(x), which is what I would expect.

javascript
1const actions = array.map((x) => act(x));
2const result = await Promise.all(actions);
3
4//or
5const result = await Promise.all(array.map((x) => act(x)));

TS Playground

popularity
On Fire
posted
Jun. 06, 2023