lets say i have this async functuin:
function fooAsync(){
callSomeApi(some_args, callbackFunction(results){
return results; //i want to return the results here after the api call.
}
}
i'm looking for a way to assign the return value from the prev function to a var and continue with the code only when i have this value.
//some code here
var foo = fooAsync();
//some code here after getting back from the async function.
the problem is that foo will be undefined since javascript will return before the inner async api call will finish. I know i can use callbacks for that but i'm looking for a way to 'lock' the async function and resume back only when it got the result. That way i wont have to pass all the code after the async call as a callback.
to make things short - how can i return value from async ajax call (in my case i call google maps api) in a regular sync way?