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
hugely underrated. so few channels are 1. this well edited AND 2. this well explained
Thank you that means a lot to hear 🙏
agree
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 🙏
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!
The first person I watch to not explain 1 phrase using 20 phrases, neat and straight to the point! thank you.
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!
Watched async videos of bigger channels first and I have to say yours was superb!
Thanks, that means a lot to hear 🙏
Best Promise explanation I have ever seen in my life!!!
Wow, thank you! 🙏
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.
perfect: short and sweet.. no fluff or dragged on and on examples.. 10/10
bruh why so underrated?! Such a marvellous explanation, straight to the point
This is perfect! Wow best explanation I've come across
Wow, thanks!
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!
Very neat n crisp information without any extra buzz! 🤗👏
the way you explain things is just perfect
Wow,this is hands down the best explanation of this topic. Thanks alot
I was so confused about this, cleared it up for me, thanks!
Thanks! This is the best video explaining await and promises I have ever seen
Great! The best explanation about the topic I've seen! Thanks!
Very clear and concise explanation. Thanks 👍
Wow, nicely explained, short and sweet No BS
Thank you, Chris, for explaining everything so eloquently. 🙏
My pleasure!
This was the first I understood async, await! Amazing video. 🤗
Awesome! Thank you!
Had listened to lot of videos and read articles. But Wow!!! Yours is best explained and perfect real time example... Love it Man!!!
This is really helpful. Will go through all ur javascript turorials now
Best explanation iv seen on this to date. Cleared up a lot for me
I never comment to TH-cam videos but I'm feeling ungrateful not to comment this one, that explanation was SMOOTH. Thank you so much!!!
😎
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!
Concise, precise and nice. Excellent!
Thanks
Loved the explanation....it helped alot thanks!!!!
Cleanest async/await explainer!
Truely helpful and insightful explanation on Promise with good examples.
I really like how you add the code to the video AS you explain it... helps break things down...
Great explanation. Thank you very much!
Awesome explanation! Thank you
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 video is literally GOLD
This is very clear and organised video. I loved it.❤
Amazing presentation and great explanation, thanku
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!
Great simple explanation, you are very good at it.
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!
Thank you infinitely for the clear explanation 😊
this is the best explanation on TH-cam, Thanks
Subscribed...short/simple easy to understand.
Amazingly explained!
coffee example is one of the best clearest ones ive seen man :D
Thanks glad you liked it mate 🙂
Your explanation was perfect, thank you for the effort.
Glad it was helpful!
Concise! Great explanation.
One of the best video i watched in 5 mins well done ❤
Best video about promises I watched so far!
crisp clear straight to the point no bullshit awesome tutorial
Thanks pal
Verrrrrrrrrrrrrry good explanation. Thank you so much.
Absolutely wonderful material!
Thank you!
Loved the explanation
The best explanation so far only uses 5 min and easy but illustrative example
Best explanation video out there!
This is the most beautiful explanation I've ever heard, thank you
Thank you! 🤩
I love these kind of explainations
This literally made my day! THANK YOU!
beautifully explained, thanks for this
Great explanation, thank you!
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
this was one of the best explanation of async and promises !
Awesome and simple explanation ❤
BEST VIDEO ON THIS TOPIC! PERIOD!
Excellent tutorial. Made it so simple
This explanation was amazing. It was not complicated at all. Thank you.
You're very welcome!
Very well explained!
Great job! it demystified the whole idea!
good refresher! thanks much!
very good and instructive video, i get it better now thank you
Well summarized, thanks
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
Great explanation, thank you.
This video was so useful, thank you for creating it. 🙂🙂
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 🙏
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 🙂
Thanks for the video Rob
Clean and precise explanation
the explanation was really helpful!
Hands down, Quality content 10/10. I subscribed the channel.
Phenomenal explanation, thank you!
Perfect explanation
The editing is top class
Very well explained!! Thank you 🙏
Thanks a lot for this great tutorial🎉
Promises & async await ARE PROUD OF YOU. such explanation💛
Thanks 🙏
Superbly put together Chris, never heard or seen it explained as well
😇
Wow, thank you 🙏😊
It's Rob
I really liked this video:
A. I like Harry Potter, and your accent reminds me of stephen fry reading the book
B. the explanation is actually short and concise, and the editing is quite nice too, something u don't see a lot around...
Thank you! 🙏 I’ve not been compared to Stephen Fry before, an honour 😎
Thanks for the video, this is very helpful
the perfect explanation bro
Great video man!
Great explanation 😊
Great explanation, thanks!
Glad it was 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
This is great. Well done!
well edited and well explained!!u deserve million subs
Thanks! We agree 😅