Hi everyone, I am trying to fill the last column in the table with a value I get back from a rest api call which takes the other columns as input.
The async and re-triggering isn't really working and the queries fail back to back... I am not a pro in Javascript...
My App
In short in each row, the price has to be filled and here is my code and I am triggering this script via the button.
async function runQuery(i) {
const allData = table1.data;
allData[i].price = 'Getting rates...';
table1.setData(allData);
const quotes = await new Promise((resolve) => {
Get_Quote_API_Request.trigger({
additionalScope: { i: i },
onSuccess: function (returnData) {
const allData = table1.data;
allData[i].price = returnData.priceResult[0].freightPrice;
table1.setData(allData);
resolve(returnData);
runQuery(i + 1);
},
onFailure: function (returnData) {
const allData = table1.data;
allData[i].price = "Error...";
table1.setData(allData);
resolve(returnData);
runQuery(i + 1);
}
});
});
}
runQuery(0);