CodeNewbie Community 🌱

Discussion on: How do I return the response from an asynchronous call?

Collapse
 
ender_minyard profile image
ender minyard

Writing synchronous code, you can retrieve the response of a synchronous call as such:

let response = function1();
Enter fullscreen mode Exit fullscreen mode

If function1 is a Promise, one could rephrase the above as

(async () => { 
let response = await function1();
})();
Enter fullscreen mode Exit fullscreen mode