Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here
Mar 20, 2022 06:54 PM
This is the code, all variables exist in this but it says can only use await on async functions:
fetch(“https://api.onfinance.in/insights”, requestOptions)
.then(response => response.text())
.then((result) => {
for(let j=0; j<checkedDataIDS.length; j++){
await table.deleteRecordAsync(checkedDataIDS[j]);
}
console.log("Processed Insights: ", checkedDataIDS);
})
.catch(error => console.log(‘error’, error));
Mar 20, 2022 07:37 PM
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.