Loop inside my raw body

Hello, im new in Retool and im trying to build a loop inside my rawbody.
I will explain you my problem.
I have a Connection to MongoDB and a Connection to a APi.

I want to make multiple post request to the API but dont like to copy my customers 1000 times and add it to the API the request is always the same like just some fields should get change with the data from MongoDB.
"bulk_connections": {
"connection": [
"customer_code": "XXXX",
"customer_name": "XXXXXX",
"customer_alias": "XXXXXXXXXXXX",

the XXXX should replace with the MongoDB data as a loop like this.

Is there any idea how do i do this?

Hello @kikiluke1,

Please have a look at this community link

It explains how to do this


I think you missunderstood my problem. I want to do multiply calls in my request body not in mongoDB.

I want that my request jump to the next data from customer_code that is given in my mongo db

You have a mongoDB query that pulls up a list of customers and you want to create a query that loops an API trigger against each customer record?

Yes right. Thats what i wanted to do

I dont think you can do this as some sort of strapped on JS on the mongoDB query. You have to first query the DB and then have a query that loops through that query triggering an additional scope like @ugo.ago suggested above. That new query should return all promises as data payload.

Like this maybe:

const arr = mongoDB.data.map(x=>x.customer_code) //your array of things to iterate over
const query = API // your query to trigger for each

const promises = arr.map((item) => {
    return query.trigger({
      additionalScope: {
        assignment_id: item //assignment_id would be available inside {{assignment_id}} in the target query when run

return Promise.all(promises)