This is what I tried -
async func1(){
// do asynchronous calls with await
console.log("call finished");
}
func2(){
func1(); // without await
console.log("func2 finished");
return;
}
func2();
The output was - func2 finished call finished
.
So even after the parent function completed execution, the async function still completed what it was intended for.
Will this work in case of an API where we are returning something to an external service? Like cloud functions -
async func1(){
// do asynchronous calls - post db using await
console.log("call finished");
}
func2(){
func1(); // without await
return response.status(200).send("");
}
func2();
Will the database call complete even if the response.send
is executed first provided I don't await
for the first function to finish execution?