I wonder how to await the outcome of multiple async functions properly:
async function call1() {
let result = await $.ajax({url: `api/call1`});
data1 = result;
};
async function call2() {
let result = await $.ajax({url: `api/call2`});
data2 = result;
};
My approach:
let somevar = function () {
call1().then( var1 => {
call2().then( var2 => {
console.log("call1", data1, "call2", data2);
});
});
};
This is how I tried it, and I am sure this is not the way how to do this.