In this tutorial I explain what Javascript promises are, why we need them, and how to use them, catch errors properly and then convert the same code to use async and await. With examples!
☕️ Don’t forget, old developers need coffee (and.. beer and pizza too 🍺 🍕)
https://www.buymeacoffee.com/Robertsdevtalk
Check out the Bored API for fun sample data:
https://www.boredapi.com/
📧 📫 Join us on our developer journey! Sign up to our email newsletter:
https://robertsdevtalk.com
🐦 Follow us on Twitter:
https://twitter.com/robertsdevtalk
🎶 Music by Epidemic Sound:
https://www.epidemicsound.com/referral/rkhnun/
Our gear – click through to support our channel! 🙂
Camera (Canon M50)
🇬🇧 UK: https://amzn.to/3sUbzuL
🇺🇸 US: https://amzn.to/3uBsG5c
Camera mic (RODE VideoMic Pro)
🇬🇧 UK: https://amzn.to/3ml8xgC
🇺🇸 US: https://amzn.to/2RkGxyi
Camera tripod (Manfrotto Compact tripod):
🇬🇧 UK: https://amzn.to/3fJGyWU
🇺🇸 US: https://amzn.to/3mF4oV2
Voiceover Mic (Blue Yeti)
🇬🇧 UK: https://amzn.to/2PV7UOQ
🇺🇸 US: https://amzn.to/3uMiEym
Chris’s dev mouse for PC (Logitech MX Master 3)
🇬🇧 UK: https://amzn.to/39K7BNV
🇺🇸 US: https://amzn.to/3uKYvso
Chris’s dev keyboard for PC (Logitech MX Keys)
🇬🇧 UK: https://amzn.to/3rSbHcX
🇺🇸 US: https://amzn.to/3a6Unef
Rob’s dev keyboard for Mac (Apple Magic Keyboard)
🇬🇧 UK: https://amzn.to/3dEQpKG
🇺🇸 US: https://amzn.to/3sb6JZc
Rob’s dev mouse for Mac (Apple Magic Mouse)
🇬🇧 UK: https://amzn.to/3sRCQhr
🇺🇸 US: https://amzn.to/3mFi6qS
Icons in this video kindly provided by FlatIcon from Freepik
https://www.freepik.com
https://www.flaticon.com
JS icon provided by Icon8 https://icons8.com
Disclaimer – some of our links are affiliate links, which means that we receive a small commission for any sales made via those links, at no extra cost to you – so a great way to support our channel! Thank you so much for your support 😊
#javascript #promises #async
source
this is what I call a perfect 10/10 explanation. "Crisp" and at the same time complete information with example.
Succinct and accurate, with good examples to boot. Absolutely stellar teaching.
Thank You !
subbed 🙂
Great explanation, thanks!
What an absolute break down. I wish all teachers had the touch to teach like you
Why would you not put await before the method you called at the bottom of the final example? the function is marked async, coming for c# you would do await getActivity()
very very good video.
perfect video thank you so much good sir
You left out the part where a Promise can be polyfilled but you require a newer JavaScript version to run await and async.
Wow that was amazing, short and up to the point. Can't thanks enough. You saved my day at work.
Wow, brilliant. I knew all this, but I would never explain it like in this video in 1000 years.
Thanks for the video Rob
Star citizen when ?
You must be my husband. I need husband like him everyone. you explain so good. i love you Robert ❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤❤🔥❤🔥❤🔥❤🔥🔥🔥🔥🔥🎈🎈
Loved the explanation….it helped alot thanks!!!!
Amazingly explained!
what happens if we put a console.log after getActivity() ? Which one will be executed first?
Why we write async before a function when we want to make the content of that function run synchronusly ?
Subscribed…short/simple easy to understand.
While this happens to be a VERY GOOD explanation of promises/await/then/catch/etc This does NOT show native js promise in action, and he is using axios for that explanation(which of course is a promise based lib). Still, very good though, thank you.
I never comment to Youtube videos but I'm feeling ungrateful not to comment this one, that explanation was SMOOTH. Thank you so much!!!
I really like how you add the code to the video AS you explain it… helps break things down…
Such a quick and easy to understand explanation. Subscribed immediately 🎉
What a fantastic, succinct overview of promises and await. Liked and Subscribed. Well done!
Cleanest async/await explainer!
Also really important to understand that try/catch inside an async block is not the same as sync control flow. It's usually transformed to a generator pattern in babel, etc
I remember when promises were a thing you included like bluebird. There's nothing special about either, they're just syntax sugar for higher order functions. I find debugging async way more infuriating than the former.
That was so much more concise and comprehensive than reading it in the doc, thanks!
Great explaination
Hitchhiker's guide to the galaxy ❤
Am I the 10,000th liker of this vid xD
Great explanation. Thank you!!
On the line of code that shows "response.data.activity" where is .data.activity coming from?
this video is literally GOLD
Awesome job 🎉
Awesome video ! 🎉
What if we need some of the same functionality in POST and GET routes? We cannot use "await" in their call back functions. Is it possible?
thank you.