+ 2
Promises in javascript
I could not understand promises in sololearn. can anyone give me suggestions to learn promises?
20 Respostas
+ 7
My fresh video tutorial about Promise
https://youtu.be/s6Nd4x_RJPw
+ 7
Shadman Sakib Are you already familiar with the conceptual meanings of synchronous and asynchronous processing?
If not, then you'll want to learn more about these concepts and the differences between sync vs async in order to better understand how promises play a role in supporting various async patterns.
+ 5
Promise is a new feature of ES6. It is most probably used to fetch data from an api. Or simple it is used to get some data which takes some time to load. When you try to load data from an api, it will generally take some time, right? And hence if you try to access the data before it is loaded, you will get errors. Therefore, the solution is to use promise. Check out this code for an example :))
https://code.sololearn.com/WApBRrc6CHB8/?ref=app
+ 5
Crash While the written expression of "facepalm" may be lost in translation, I bet you'll instantly know the emoji version of this meaning... š¤¦āāļø
If that's still unfamiliar, this link should help: šš
https://en.m.wikipedia.org/wiki/Facepalm
+ 5
After learning Promise, learn
#2 async / await
https://youtu.be/2RzzTapgTvM
It saves us from having to use a lot of callback functions.
After that, learn the applications of asynchronous programming :
#3 Using fetch() to send HTTP GET Request to fetch JSON data from API - with randomuser as demonstration.
https://youtu.be/is0QYV0oHx0
#4 Web Scraping with fetch() and cors-anywhere.herokuapp and DOMParser, with logo of my website as example.
https://youtu.be/pZbrP9ZDf6s
All videos are just freshly recorded, here is a playlist of my JS Asynchronous series :
https://www.youtube.com/playlist?list=PLkqwj9vc20pX36wThr2A6DZx4MVcJvnhe
+ 3
Shadman Sakib To understand Promise, firstly you have to understand asynchronous function as what David Carroll highlighted.
Secondly, you need to understand the arguments of new Promise(okCallback, errorCallback), which are the callback functions, we would use okCallback(data) when we return the working result, data of a function (normally async function). And we would use errorCallback(error) to return error, when the async function encounters error.
Next question is
"How does the function get the async parameter of okCallback or errorCallback function?"
We chain the return of new Promise object with then and catch functions (.then( d=> console.log(d)).catch( err => console.log(err))).
Eventually we could expect the parameter of okCallback would be parameter input of .then callback. And errorCallback parameter would be parameter input of .catch callback.
Study this simple example https://code.sololearn.com/W0947gjP8TOf/?ref=app
+ 2
open async function
it is a mini series :
https://code.sololearn.com/WKKkpq0efxai/?ref=app
+ 2
+ 2
https://javascript.info/promise-basics
+ 2
You may find answer in :-
1) https://www.geeksforgeeks.org/javascript-promises/
2) https://web.dev/promises/
+ 2
narayanaprasad I'm usually disappointed in the poor quality of many articles published these days.
That said, I was quite impressed with the quality of the web.dev article.
I typically avoid wasting my time reading content from geeksforgeeks.org. There's only so much disappointment and face-palming one can take. š
In any case, thanks for sharing the web.dev article.
+ 1
I can't understand sololearn promises
+ 1
thanks all āŗ
0
give me other sources than sololearn
0
ok
0
thanks
0
Hi David Carroll
I think I have a language problem.
What does "face-palming" mean?
Is it when you clap your hands onto your face like this: š?
0
Thank's David Carroll ,
that's what I meant when I posted my 'monkey'...
I think the German equivalent would be: 'sich an den Kopf fassen'.
=>'touch your head'.
0
nice language battle guys š
0
@Gordon š
difficult things