DEV Community

Discussion on: "Synchronous" fetch with async/await

Collapse
 
petko3000 profile image
petko3000

Guys, i would like to solve one issue with this async function. How to load output from that function to a variable usable in later non-async code? Like lets say i collect data from couple of APIs within async function, then i need to do some logic on top of that data with non-async code.

Collapse
 
spine001 profile image
spine001

You can pass an objetc to the function, and then take care to only change the content of the object without making a copy of it, then what is passed is the address of the object. And when you modify it with methods of the object that don't make copies, you will be modifying the object itself outside the scope of the function.
I imagine that you already solved this but since I haven't seen anybody ever give you an answer I am posting this to help others with the same problem.