Loading
Current section: 2. Async/Await 5 exercises
lesson

Intro to Async/Await

Loading lesson

Transcript

00:00 Alright. We're about to really clean up our promise code because async await is here to save us. So promises can be a little confusing adding all these callbacks everywhere. And async await is a special syntax that was added to JavaScript years ago to make handling this a lot simpler. So here's what you do with promises.

00:19 You get your user and then you handle this and then you handle the error. With async await, it's as simple as this. You just add an await keyword. There's also an async keyword which you have to add to any functions that are gonna use the await keyword because functions are gonna turn into asynchronous things if they are using await. And so we simply wait for the user.

00:40 The code execution stops and we get the user and then we can do whatever we want to with the user. And if there's an error, then it will fall in the catch just like our synchronous JavaScript. So it's a really elegant solution to the code organization, problem with asynchronous code. Really happy with it and, it's really important for you to understand how promises work to use this to its utmost effectiveness. But I'll be honest, even if you don't understand promises completely, you can still use async await, very pretty effectively.

01:09 So, but don't don't let that be a crutch for you. If you don't understand promises, then like do some more reps and and make a good understanding of of promises. Alright. I think that's enough to let you jump into this one. So we'll see you in the exercise.