I just ran this script, it made all my prices to 0. Not good. Please help.
I am trying to convert prices from EUR to USD.
I found this script on airtable.
// Change this to the name of a table in your base
let table = base.getTable('Seeds');
// Fetch conversion rate from API - you could change this to any API you want
let apiResponse = await fetch('https://api.exchangerate.host/latest?base=USD');
let data = await apiResponse.json();
let conversionRate = data.rates.EUR;
console.log(`Conversion rate: ${conversionRate}`);
// Update all the records
let result = await table.selectRecordsAsync();
for (let record of result.records) {
await table.updateRecordAsync(record, {
// Change these names to fields in your base
'Price EUR': record.getCellValue('Price USD') * conversionRate,
});
}