Get list from retool database and trigger api for each row (almost working but....)

Hi All,

got pretty far with below but got one remaining challenge :slight_smile: The end result of this is to trigger a rest api that can only handle one ean code per call, it should iterate through the list of ean codes coming from my retool database and show all results in one table (well that's step 1)

Currently it will get all the data from the API but it will refresh the table every time he finished the call and will then only show the data from the latest call

Query retool database

Run JS code

API

So in short I think I am missing a step where I collect the data and need to save it somewhere?

Where is restean living?

That should be the variable from the JS code to the Rest APi

Ah, got it now I think!
I also see that you haven't prefixed your query5 with return - line 1 should start as

return query4.data.fo [..]

Sorry not a js expert, with help of some other forums I tried this

let apiData = [];
getean.data.forEach(row => {
eanloop.trigger({
additionalScope: {
restean: row.ean
}
}).then((returnedData) => {
apiData.push(returnedData);
});
});
Promise.all(apiData).then(response => { return response });

still the same, it loops through the data and I see my api table changing and only showing the latest call but my js query data output is still null

I love ChatGTP, got it working but question remaining is now how to format this data in a normal way for my able?

Hey @Sander!

It looks like your API is already returning arrays of data, can you try changing your transformer to something like

return data.flat();

instead of

return formatDataAsArray(data);

@Kabirdas you rock (again) thanks for the help it's working now.