+ 1
Problem with returning value from asynchronous function using callback
Here in my code, I want the processInput() to return the final result, but I am actually dealing with asynchronous function that returns a promise, so I am feeling harder to do it. Anyone can help me plz. My requirement is the function "processInput()" should return the result. https://code.sololearn.com/WAZ9kYhNzsaH/?ref=app
3 Réponses
+ 3
March Zucherberg
I got the problem
The console log runs before it gets the data.
If your log the value in the call back function then it works
+ 3
And also if you are using promise then no need to use async await.
+ 2
Refactored according to your requirement.
https://code.sololearn.com/Wa0A0a5a76A2