DEV Community

Discussion on: Async Await usage and pitfalls in and chaining

puruvj profile image
PuruVJ Author

Thanks for the suggestion. I left in all those extra async awaits to show these functions return promises. Otherwise, I simply remove async and await if the function returns a promise.

const usersData = await Promise.all( => getUserData(id))
stexx profile image
Stefan Breitenstein

Sure but I talk about the explicit the await, not the async part.

And here is a nice part of async functions:
They results always in a Promise, so you don't have to care about the return statement.
At least with the Promise/await part.

So what i mean

const usersData = await Promise.all( (id) => getUserData(id)) // returns always a promise, no gain to write also await.

There is even a eslint rule for that:

I think they explain the benefits and tradeoffs better than me :)