API Call Using/Returning Last Set of Values

I have sent a video via chat, showing this issue.

I am calling an external API. I am populating the parameters for that call using additional scope as follows

async function lookup() {
await apiData.trigger({additionalScope: {
t: "retool-datalookup",
comp: s2n(editVaFirm.value),
a1: s2n(editVaAddr.value),
city: s2n(editVaCity.value),
state: s2n(editVaState.value),
postal: s2n(editVaZip.value)
//where s2n is a helper function in global JS


//json response
var returnedData = apiData.data.Records[0];

await lookup();

The value assigned to returnedData is the data from the prior call. So if I call it with "123 Main St" in editVaAddr it returns what ever the last call contained. Then, if my next call is done using "567 Walnut Lane" returnedData will contain the data for "123 Main St". The next call would return data for "567 Walnut Lane" and so on. Hopefully that is clear.

It sounds like an API issue not a Retool issue but if I cut and paste the URI into Postman using the same data it works correctly. I get back the data relevant for the address I submitted. Any ideas? Thanks.

Hey @pushbtn!

The query.trigger() promise return the data property of the current call, so you should be able to run something like:

var response = await apiData.trigger(...);


var returnedData = response.Records[0];

Could that pattern work in your script?

Thanks, that was it. Moved from promises to async functions but will reincorporate.