I have different functions running in different if statements. I want to go back to the previous else if
after the one of the other has been run. I tried to write a promise but that ran too soon.
My code:
(async() => {
let dev = await getAllTables({
query: tables(dev_id)
});
let prod = await getAllTables({
query: tables(prod_org)
});
result.data.table_fields.forEach((d) => {
if (d.type != "connected_field") {
axiosfunc1();
} else if (d.label in dev) {
axiosfunc2();
} else if (d.label in prod) {
axiosfunc3()
.then((res) => res)
.then((x) => {
axiosfunc2();
});
} else {
console.log(`${d.label} DOES NOT EXIST}`);
}
});
})();
axiosfunc2()
is running at the same time as axiosfunc3()
rather than having axiosfunc3()
run first and then axiosfunc2()
.
How do I fix that?