DEV Community

Discussion on: I Promise this is a practical guide to Async / Await

Collapse
lampewebdev profile image
Michael "lampe" Lazarski Author • Edited on

Hey Namir,
Thanks.

yes, this is another solution is to chain the promises. Like I have written that the given first example is just an example I have seen and should be more an anti-pattern. If you chain a lot of promises, so what you want to run your code in a sequential manner then I think that Await / Async is the even more readable solution.

time = await resolveAfterXSeconds(2000);
console.log(`resolved after ${time}`);
time = await resolveAfterXSeconds(1000);
console.log(`resolved after ${time}`);