Javascript Promises vs Async Await EXPLAINED (in 5 minutes)
Вставка
- Опубліковано 17 сер 2021
- 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 🍺 🍕)
www.buymeacoffee.com/Robertsd...
Check out the Bored API for fun sample data:
www.boredapi.com/
📧 📫 Join us on our developer journey! Sign up to our email newsletter:
robertsdevtalk.com
🐦 Follow us on Twitter:
/ robertsdevtalk
🎶 Music by Epidemic Sound:
www.epidemicsound.com/referra...
Our gear - click through to support our channel! :)
Camera (Canon M50)
🇬🇧 UK: amzn.to/3sUbzuL
🇺🇸 US: amzn.to/3uBsG5c
Camera mic (RODE VideoMic Pro)
🇬🇧 UK: amzn.to/3ml8xgC
🇺🇸 US: amzn.to/2RkGxyi
Camera tripod (Manfrotto Compact tripod):
🇬🇧 UK: amzn.to/3fJGyWU
🇺🇸 US: amzn.to/3mF4oV2
Voiceover Mic (Blue Yeti)
🇬🇧 UK: amzn.to/2PV7UOQ
🇺🇸 US: amzn.to/3uMiEym
Chris's dev mouse for PC (Logitech MX Master 3)
🇬🇧 UK: amzn.to/39K7BNV
🇺🇸 US: amzn.to/3uKYvso
Chris's dev keyboard for PC (Logitech MX Keys)
🇬🇧 UK: amzn.to/3rSbHcX
🇺🇸 US: amzn.to/3a6Unef
Rob's dev keyboard for Mac (Apple Magic Keyboard)
🇬🇧 UK: amzn.to/3dEQpKG
🇺🇸 US: amzn.to/3sb6JZc
Rob's dev mouse for Mac (Apple Magic Mouse)
🇬🇧 UK: amzn.to/3sRCQhr
🇺🇸 US: amzn.to/3mFi6qS
Icons in this video kindly provided by FlatIcon from Freepik
www.freepik.com
www.flaticon.com
JS icon provided by Icon8 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
2:25 "Then is called when the task completes... the catch method is called if anything goes wrong". This is wrong. These methods are called immediately. It's the functions that you pass to them that are called on those conditions. This may sound like pedantry but I would strongly suggest anyone trying to learn this to fully understand the distinction here.
Good catch, thanks. Pinning this comment.
Only if - there be - () call f(x) - pre amp d(x)! It never did - ught yet?
"It's the functions that you pass to them that are called on those conditions. " what do you mean by "on those conditions"? do you mean the functions passed to then() and catch() are called after the task completes? im confused about this sentence
@@jellyjollyjelly9513 I think he is saying the method 'then' is called immediately when that line is executed. It is a method of a Promise. It binds a callback function that will be called when the promise returns fulfilled.
'The 'then' method is called when the task completes' would be wrong and should be
'The callback function passed to the 'then' method will be called when the task completes'
the .then anc .catch methdos being called inmediatly ever affects something? why giving the distinction between the execition of the methods en the code inside it if nothing will happen until the promise es fullfield? i guess there is something but cant thing of a case
this is what I call a perfect 10/10 explanation. "Crisp" and at the same time complete information with example.
Thanks for your kind words and support of the channel Nakshatra
@@RDT The tutorial was beyond. It was quick BUT delivered ALL the information I was looking for. Thank you so much Roberts Dev Talk, wow!!!!!!!!😮😃😍
Yeah! Example Makes it way easier to understand compared to just explaining the theory.
It’s important to point out that working with multiple apis you often have to chain multiple promises resulting in callbacks nested inside callbacks nested inside callbacks nested inside callbacks…you get the idea. 😅This is what we call a CALLBACK HELL. So the primary reason async/ await exists is to avoid a callback hell
Absolutely 👍🏻
This is what I was looking for...thank you for asking this!
@@kkdpsudpsu Promise.all is not suitable when you need to ensure the first API call's response is available before making another API call that relies on it.
I just want to call another api using first call's result. What method I have to follow ?
By the way, i am using subscription for the first call
dude this just made so many lightbulbs go off in my head and tied so many things together for me. thank you
Thanks! Glad to hear it helped - I hoped it would do 🙏
perfect: short and sweet.. no fluff or dragged on and on examples.. 10/10
Good lord, it's the most clear explanation i've ever watch. Thanks bro
bruh why so underrated?! Such a marvellous explanation, straight to the point
hugely underrated. so few channels are 1. this well edited AND 2. this well explained
Thank you that means a lot to hear 🙏
agree
The first person I watch to not explain 1 phrase using 20 phrases, neat and straight to the point! thank you.
After struggling with various definitions of async/await, I stumbled upon this video which made everything crystal clear. Thank you so much Mr. Sir Roberts for simplifying things!
You're very welcome!
Great analogy with the waiter bringing coffee to explain promises! It really clarifies how promises work in JavaScript. Using then and catch makes handling asynchronous operations much cleaner. Thanks for breaking it down so well, Kyle!
I was so confused about this, cleared it up for me, thanks!
Wow,this is hands down the best explanation of this topic. Thanks alot
I find that alot of 'programming words' are quite strange. It may sound complicated but it just needs someone to use the right explanation and then it clicks. A very helpful video, much appreciated.
Very neat n crisp information without any extra buzz! 🤗👏
the way you explain things is just perfect
Thanks! This is the best video explaining await and promises I have ever seen
Oh my God!!! This explanation is perfect! I was really struggling to understand both promises and async functions, but now I see it all! Thank you so much!
Umm... This is by far the most simple and logical explanation of this topic I've seen. In five minutes I've gone from writing code I didn't understand to totally getting it. Thank you!
Excellent!
of all the videos I watched, this is by far the most simple explanation of promises then, catch vs async await, thank you for this video
You're very welcome!
After months of struggle finally understanding Promises thank you so much Robert. Definitely subscribed 🥰
Thanks for the sub Mehmet! Glad the video helped you 🙏
This is really helpful. Will go through all ur javascript turorials now
I really like how you add the code to the video AS you explain it... helps break things down...
Had listened to lot of videos and read articles. But Wow!!! Yours is best explained and perfect real time example... Love it Man!!!
Wow, nicely explained, short and sweet No BS
Watched async videos of bigger channels first and I have to say yours was superb!
Thanks, that means a lot to hear 🙏
Best explanation iv seen on this to date. Cleared up a lot for me
Great! The best explanation about the topic I've seen! Thanks!
Thank you, Chris, for explaining everything so eloquently. 🙏
My pleasure!
This is the best explanation with the best examples I've ever seen about async in Javascript. Thank you very much!!
You're very welcome!
coffee example is one of the best clearest ones ive seen man :D
Thanks glad you liked it mate 🙂
The best explanation so far only uses 5 min and easy but illustrative example
Truely helpful and insightful explanation on Promise with good examples.
A VERY CLEAR handling of this often-confusing topic. You just EARNED another subscriber !
-Mark in North Aurora IL (USA)
Thanks for your support Mark 🙂
Briliant video, very simple and easy to understand, it's nice that you're comparing the two in one short video. Thank you!
Thanks for your kind comments and support
This is the most beautiful explanation I've ever heard, thank you
Thank you! 🤩
This explanation was amazing. It was not complicated at all. Thank you.
You're very welcome!
this is the best explanation on UA-cam, Thanks
What an absolute break down. I wish all teachers had the touch to teach like you
LOL he taught it the wrong way LOL!!!!!!!!!! you are clearly learning from wrong content, poor guy
Very clear and concise explanation. Thanks 👍
One of the best video i watched in 5 mins well done ❤
This is perfect! Wow best explanation I've come across
Wow, thanks!
I've been trying to figure out promises and async for days and it finally makes sense. Thanks!
Best video about promises I watched so far!
This was the first I understood async, await! Amazing video. 🤗
Awesome! Thank you!
super well explained, I have watched tons of videos and I finally feel like I understand it!
Thanks Elisa, glad it was helpful to you 🙏
Loved the explanation....it helped alot thanks!!!!
Been a bit confused about the promises, async await, and try catch thing. But not anymore. Best explanation :D
This is very clear and organised video. I loved it.❤
this was one of the best explanation of async and promises !
Great simple explanation, you are very good at it.
Your explanation was perfect, thank you for the effort.
Glad it was helpful!
This literally made my day! THANK YOU!
Great explanation. Thank you very much!
Cleanest async/await explainer!
Awesome explanation! Thank you
Superbly put together Chris, never heard or seen it explained as well
😇
Wow, thank you 🙏😊
It's Rob
Thank you infinitely for the clear explanation 😊
Well, I can't find words to thank you enough... You helped me understand promises in 5min! Thank you so much!
Hands down, Quality content 10/10. I subscribed the channel.
Verrrrrrrrrrrrrry good explanation. Thank you so much.
Promises & async await ARE PROUD OF YOU. such explanation💛
Thanks 🙏
Amazing presentation and great explanation, thanku
This video was so useful, thank you for creating it. 🙂🙂
this video is literally GOLD
this is definitely the best tutorial i have came across. Well done
Amazingly explained!
good refresher! thanks much!
well edited and well explained!!u deserve million subs
Thanks! We agree 😅
crisp clear straight to the point no bullshit awesome tutorial
Thanks pal
Beat explanation of these two concepts I’ve ever heard. 👍
That’s really kind, thank you
Excellent tutorial. Made it so simple
very good and instructive video, i get it better now thank you
I love these kind of explainations
Awesome and simple explanation ❤
Subscribed...short/simple easy to understand.
Best explanation video out there!
BEST VIDEO ON THIS TOPIC! PERIOD!
beautifully explained, thanks for this
Loved the explanation
Concise, precise and nice. Excellent!
Thanks
Really smooth, subscribed!
Thanks Sanam
Well summarized, thanks
That was short and simple, thank you!
Thanks for your support Loyd
This is great. Well done!
Jesus, your explanation literally make me happy and smiling reading the code, 10/10
Thanks! 🙏
Thanks for the video Rob
Best short explanation I’ve ever seen!
Thanks for your kind comment and support Alvaro
@@RDT Ofc, you deserve it 🙂
Great explanation, thank you.
Great video! Clear explanation, straight to the point in 5 minutes.
Very well explained!
Phenomenal explanation, thank you!
the explanation was really helpful!
Phenomenal explanation! You make my day sir
Glad you liked it! Thanks
Thanks a lot for this great tutorial🎉
The most succinct explanation on this topic I've heard. Thank you!
Thanks for you kind comments and support of the channel
great explanation i have been struggling on google but you made it so easy.
Glad it helped you Ansh, I tried to make the video I was looking for when I was trying to understand it!
Thanks for the video, this is very helpful
This was a great explanation. Despite programming for 25+ years, I've used Promises a ton in JS and C# I've used promises there too and never really understood that await/async was basically the same thing just sequential. 5 stars on your explanation!
Thanks
Best Promise explanation I have ever seen in my life!!!
Wow, thank you! 🙏