That’s because you are only allowed to use await in async functions. You use await when you delete the record in the anonymous function in your second “then”.
It is probably easier to understand if you use a different syntax.
async function doStuff() {
const response = await fetch(“https://api.onfinance.in/insights”, requestOptions)
const result = await response.text()
for(let j=0; j<checkedDataIDS.length; j++) {
await table.deleteRecordAsync(checkedDataIDS[j]);
}
}
You would also be better off submitting the delete requests in batches, instead of one at a time.