How to use await in Promises?

Hey @rolandapercur, you would need to wrap your script in an async function where await is permitted.

Try this:

(async () => {
  var array = table15.data;

  for (let i = 0; i < array.length; i++) {
    await new Promise((resolve) => {
      get_did_pagex7.trigger({
        additionalScope: {
          criteria4: array[i].Dealer_s_Id_associ_s.id
        },
        onSuccess: (data) => {
          resolve(data);
        }
      })
    });
  };
})();

Does this work for you?

1 Like