Actually in your first example I find the then() based approach much more readable than the async/await approach, because the data is being chained or piped through the lines. I also think about it as a more functional way, whilst async/await is the procedural way.
I wouldn't always prefer then() over async/await. The latter is especially more suitable when there's just a single promise.
Yep, it's definitely a stylistic thing from time to time. To be honest, if you use TypeScript, the types flow through .then chains very nicely as well, so I don't really have a problem with that. I just don't really like that people sometimes stick async on a function for no apparent reason, possibly without knowing what it does and what it's for, so that was my main motivation to write this blog post :)
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Actually in your first example I find the
then()
based approach much more readable than theasync/await
approach, because the data is being chained or piped through the lines. I also think about it as a more functional way, whilstasync/await
is the procedural way.I wouldn't always prefer
then()
overasync/await
. The latter is especially more suitable when there's just a single promise.Yep, it's definitely a stylistic thing from time to time. To be honest, if you use TypeScript, the types flow through
.then
chains very nicely as well, so I don't really have a problem with that. I just don't really like that people sometimes stickasync
on a function for no apparent reason, possibly without knowing what it does and what it's for, so that was my main motivation to write this blog post :)