I have a function that returns some data based on conditions but in my else I want to call 2 functions but I want the first one to run before the second one does. I think I can add a promise here but I am not sure how to do that.
My code:
result.data.table_fields.forEach((d) => {
    if (d.type != "connected_field") {
      // do something
    } else {
      getAllTables({ query: tables(dev_id) }).then((res) => {
        if (d.label in res) {
          // do something
        } else {
            getAllTables({ query: tables(prod_org) }).then((prod) => {
               if (d.label in prod) {
                  //do something
               } else console.log(`${d.label} DOES NOT EXIST}`);
            });
        }
      });
    }
  });
Is there a way to do this without nesting the functions. I need to check if the value first exists in dev before checking prod.
 
    