Loop through queries and store results

I have a list of different values that I want to use in a query and store the results. I can loop through all the values and trigger a query by using additionalScope. Then the query I am using has an onSuccess event handler that uses set_in to store the data in a temproary state.

The problem is, every time I run it I get success notifications for each query that runs, but only one value stores in the temporary state. If I run each query individually it works fine, but its almost like the queries run too fast, so by the time the onSuccess runs the value of that query has already changed.

Is there a way to do this? The query I am doing is reading a file from S3. Basically I have data stored as json in different folders and I need to access that data.


Hey @szabon (the famous computer scientist!?) – I'm pretty sure what's happening here is that your data is getting overridden because you're not using async/await. I don't fully understand what your code is doing or I'd give you a more in depth answer, but can you try to convert it to async? Both the query trigger and the .setValue() calls.