Below is my code.
Our table is fed by a form that our real estate agents use to track their marketing efforts.
At 8AM daily, we have an automation that runs the following script.
// query for all the records in my ON MARKET table
let table = base.getTable("Ads");
let view = table.getView('On Market')
let query = await view.selectRecordsAsync();
// for each record, check rental platform api for any updates in status or pricing
for (let record of query.records) {
let response = await fetch(`https://www.domain.com/api/rentals/search.php?key=API_KEY_REMOVED&request_type=%22JSON%22&listing_id=${record.getCellValueAsString("ID")}`);
let data = await response.json();
data = data.listings[0];
// console.log(data) **testing only**
await table.updateRecordAsync(record, {
'Status': {name: data.status},
'Street Number': data.streetNumber,
'Street Name': data.streetName,
'Unit': data.unit,
'City': data.city,
'Rent': data.price,
'Source': {name: data.source}
});
// output.set('data', data)
}
It worked perfectly, until the table got a little bigger.
Today I started receiving the following error:
Error: Exceeded quota of 50 fetch requests per script invocation.
The issue is, my table will continue to grow to 5,000+ records.
Is there any way that I can invoke the script in batches? I know it’s possible because DataFetcher does something similar.