...
/Tip 44: Create Clean Functions with Async/Await
Tip 44: Create Clean Functions with Async/Await
In this tip, you’ll learn how to streamline promises with async/await.
We'll cover the following...
In the previous tip, you saw that promises are awesome. They’re a vast improvement over callbacks, but their interfaces are still a little clunky. You’re still working with callbacks in methods. Fortunately, the language continues to improve. You can now avoid callbacks entirely by adding asynchronous promise data to a variable in a single function.
async
& await
Developers usually talk about the new syntax, async
/await
, as a group, but it’s really two separate actions. You use the async
keyword to declare that an
encapsulating function will be using asynchronous data. Inside the asynchronous function, you can use the await
keyword ...