Hello guys, I have an Airtable managing my bills in multiple currencies.
I’ve been trying to customize the eAirtable Currency Converter]
(Airtable Scripting) to convert each record with the conversation rate of its date. I want it to be automated given that I have 5,000 records of bills.
I suspect my syntax is wrong, but maybe the logic of my code is completely wrong too.
My code is the following :
// load table and records
let table = base.getTable("Table 1");
let result = await table.selectRecordsAsync();
// launch a 'for' loop to fetch conversation rate then update each record depending on value of "Date" field
for (let record of result.records) {
await
// fetching exchange rate
let apiResponse = await fetch(`https://api.exchangeratesapi.io/${record.getCellValue("Date")}?base=EUR`);
let data = await apiResponse.json();
let conversionRate = data.rates.GBP;
// updating the record
table.updateRecordAsync(record, {
'Exchange rate': conversionRate,
});
}
The code doesn’t work. Thank you for your help / insights / corrections.