Populate Table dynamically with existing data

So I have populated one table from csv file. For each row of the table I am quering a graphql endpoint that returns me some data. I want to populate other table with these results. Currently what I am doing is: taking table's data and running a forEach on data and triggering the api. Then my result table is populated with {{query_api_response.data}} so it is being overwritten with every iteration.

Need some suggestion how I can append the data to the table and not replace it.

Personally, I would append the result of query_api_response to a state containing an array upon query_api_response success (query success script).

I would also create a script that reset the state to an empty array and then do your trigger loop / for each

Hey , currently I am using localStorage for that , so data is appending and showing them in resuld table but was thinking if there's some obvious way to achieve these with retool's builtin utility.
Thanks

Here is an advanced use case where we can execute a query for each rows of a table or query and get all results at once
https://docs.retool.com/docs/scripting-retool#promising-an-array-of-query-returns

This example take for granted that you use the id variable in query1

const promises = table1.data.map((row) => {
  return query1.trigger({
    additionalScope: {
      id: row.id,
    },
  });
});

return Promise.all(promises);
1 Like