DEV Community

Discussion on: Simple code is different from simplistic code: Elm vs JavaScript

Collapse
 
xem0n profile image
Xem0n

I know it's not really topic-related but why did you use a promise chaining in an async function? Seems redundant

Collapse
 
marciofrayze profile image
Marcio Frayze • Edited

I'm not sure if I understood what you said, but the (async function() { is necessary otherwise I'll get a Uncaught SyntaxError: await is only valid in async functions, async generators and modules.

And I used a then chaining just because I find it more declarative (a more functional style code).

And if I take off the async and the await, then the hideLoadingMessage function will run before the fetch finishes. But maybe I could chain it as well, or something, and then the async/await could be taken off.