Async/Await
Explore how to implement async/await in Transcrypt to handle asynchronous requests in front-end development. Understand how this approach simplifies code, improves error handling, and makes asynchronous Python look more synchronous when transpiled to JavaScript.
We'll cover the following...
Introducing async/await
While the promise model does allow us to make asynchronous calls to our back-end server, the model tends to be a bit clunky. It can not only be difficult to catch errors but can also be difficult to debug with all the callbacks and promise objects. For this reason, many people prefer to use the async/await model instead, which wraps the promise model and allows our code to look more like it would if we were using a synchronous approach.
We can change our Python fetch() function to use the async/await model instead of the promise model in ...