For further actions, you may consider blocking this person and/or reporting abuse
Read next
Is React-query out of date? This new favorite makes cross-component requests a breeze!
Eddie Kimpel -
Using Guard Clauses Instead of Try-Catch in Async/Await: A Clean Coding Technique for Readable and Maintainable Code 🦄🚀
muthu raja -
From useEffect to React Query: Modernizing your data management in react
Diona Rodrigues -
How to Use the Sui TypeScript SDK
Ukeje Chukwuemeriwo Goodness -
Top comments (7)
It's funny you should ask, I was just reading the MDN Docs about this yesterday. They explain the whole concept of Promises really well. Their explanation of what promises give you vs. callbacks is a good one:
Basically promises are much more composable + predictable than callbacks, but I heartily recommend reading through the whole article to get a better overall idea.
Thank you Donald.i am going through the MDN article.
Hope this helps in solving the "callback hell":
Awaiting for async promises in JavaScript
rhymes
A promise in JavaScript is an abstraction around the idea of an asynchronous callback that supports chaining. This makes the code read to the humans like it is procedural. Do step #1 then step #2 then step #3 all while allowing the computer to handle all the asynchronicity in the all the calls.
It turns this code...
...into this code.
I blogged about this a few months ago on my company's blog here.
Thank you Guy !! that was a neat and simple explanation.
This post: scotthannen.org/blog/2016/03/01/ch...
Shows a side-by-side (or above-and-below) example of the same code with callbacks and with promises. It was a few years ago. I probably wouldn't cram all those promises into one line of code like that. But even still it shows the simplification.
Thanks for sharing the article :)