How do I achieve the following, making sure functionB() executes after functionA() finishes?
I think what you want is a third async function and then call that one. Like this:
function functionThatCannotHaveAsyncKeyword() {
functionC()
.then((resp) =>{
// this code will execute after functioA and fucntionB finish.
// They will execute in that order thanks to functionC.
});
}
async function functionC() {
await functionA();
await functionB();
}
async function functionA() {
console.log('first');
await someServiceThatMakesHTTPCall();
}
async function functionB() {
console.log('second');
await someServiceThatMakesHTTPCall();
}