Loop to run API requests using data from a mutli row select table

Hello all,
I'm begining with building App with retool, and I want to add a little bit more complexities to my first app.
Basically, I have a table with multiple accounts: Acc1, Acc2, Acc3, ...
I use an API request to collect data from these accounts.
POST request?account=Acc1

For the moment it's only possible to select 1 account in the table, so when I click on the button the request runs for the selected account.

Now, I want to be able to select more than 1 account, and then run as many POST requests as selected accounts.
I think I should use a JS query to create this loop like this

nb_acc = number of selected account
Loop from 1 to nb_acc
POST request?account=acc[i]

But I'm a bit lost in how to use JS to create this loop.
Is there a no-code way to do it or not?

When I'll be ready with this, I'd like to add more and more complexity, by adding another loop in this first loop with another parameter 🫣

Thanks for your help.

@Pierrick81 You should be able run a query to select all accounts from the your db...
select * from yourtable where account IS NOT NULL or
select * from yourtable where account != ''
And then once you have that result you can iterate through it in a couple of ways, but let's start there... more information will help. (screenshots, etc.)

1 Like

Hey ScottR
Thanks for your answer.
I'm not requesting a SQL database, but an API.
I've got a Table with a multi-select like this one:

And then, I want to run as many API requests as selected rows in this table, with a specific parameters.

  • 1st API request with Bolt as parameter
  • 2nd API request with Freenow as parameter

But I can have only 1 row selected or 4 or 5 rows selected.

Thanks for your help.

You can iterate over the choices and pass them in using additionalScope.... Check out the following example:

1 Like

I did it.
Thanks for this link. It was very helpful.