Change Run an API request for each row in a table Example

Hello,

I would like to underline my difficult to follow your example doc. I'm referring to Run an API request for each row in a table. In this example the query call an API that doesn't works so basically the output is an error.
Instead of using an API that produce an error, why don't create an example of an API that works? So users can actually understand how use the data obtained from the query2 and understand how to use it in Retool?

Hey @abovethecloud,

Thanks for surfacing this! I've passed the information along to the docs team and will let you know here when there's an update to our docs.

If you'd like to return the value from each query I recommend checking out this community post! It uses a slightly different pattern but is ideal for returning all the query values.

If you'd like to stick with the pattern used in the example then the idea is that you handle the data returned by each query in the onSuccess function that's passed. In the example, that function only calls the next query, but you might notice that you have access to the data variable there:

So, for instance, if you wanted to you could store that data in a temporary state with something like:

onSuccess: function (data) { 
   yourTempState.setIn([i], data);
   runQuery(i + 1); 
}

This uses the setIn function to store the returned data from your query in your temporary state at the same index you're using throughout the rest of query. Let me know if that helps!

1 Like