+ 2

How to return the response from an asynchronous call in Javascript?

19th Sep 2019, 4:15 AM
Darshan Raval
Darshan Raval - avatar
1 Answer
+ 1
use promise if possible. or create a callback. function foo(){ asyncfunction(paramX, callback); } function callback(result){ //the result goes here } function asyncfunction(x, callback){ //dosomething with x callback(result); }
19th Sep 2019, 6:03 AM
Taste
Taste - avatar