So i have a main function that is async and it awaits my other function.
main = async () => {
await this.getResult();
console.log("end2")
}
so here is the getResult function
getResult() = async () => {
const result= await fetch(``, this.requestOptions)
console.log("end1");
Promise.all(a.map(async b => {
console.log("Transaction", trabnsaction);
}))
}
end2 gets printed out first.
You should add the await in the Promise.all as well.
getResult() = async () => {
const result= await fetch(``, this.requestOptions)
console.log("end1");
await Promise.all(a.map(async b => {
console.log("Transaction", trabnsaction);
}))
}
You need to return Promise.all, also you need to return a promise from the map method.