How to loop through an array and hit an API for each value in a column

Gotcha @Veronica - so in short here's what I'd do:

1. Set up a query to hit the Twilio endpoint, and add in dynamic params for the TO field

If you have the Twilio endpoint already connected as a REST API resource, you can use that. I'm just using a generic REST query, and added From and To params. In the To one, I put in a variable (which we haven't defined yet – which is why it's red) called {{ dynamic_to }} - this is going to pull in the phone numbers from the table.

2. Create a Run JS Code query to iterate through the table data

Assuming your table is backed with some query like getUsers.data, we'll iterate through that and trigger that first Twilio query for each one. Using the additionalScope param, we're passing in each particular row's phone number, which is populating that dynamic_to variable that we put in the first query.

3. Hook up the Run JS Code query to a button

Or whatever component you want to use to run it.

LMK if this helps!

6 Likes