Data Returns NULL from JS Query even though console prints correct variable

Wondering if anybody knows why I can't get this data into a table?

This is my query:

var dataObjects = []
var errors = "";

function runQuery(i) {
  if (i >= jsonEditor1.value.length) {
    console.log("Finished running all queries with output", dataObjects);
    return dataObjects
  } 
  console.log("i:", i)
  multiAddressSummary.trigger({
    additionalScope: {i: i},
    onSuccess: function (data) {
      dataObjects.push(data)
      runQuery(i+1)
    },
    
    onFailure: function (error) {
      errors += "Found error at line" + i.toString() + ": " + error + "\n\n";
      runQuery(i+1)
    }
  })
}

runQuery(0)

However, my table says that the data from the query is NULL. How do I get it to return the right data?

Hello @jbreite39

From the screenshot you supplied, are you looking to use the data property from multiAddressQuery OR multiAddressSummary?

Also before you can get data in the multiAddressQuery, you need to run the query, have you done this?

Hi @jbreite39

Would it be easier to just do this?

const promises = [...Array(jsonEditor1.value.length).keys()].map((i) => {
  return multiAddressSummary.trigger({
    additionalScope: {
      i: i
    },
  });
});

return Promise.all(promises);
1 Like

That worked! Appreciate the help!