Fetching extra fields using the Airtable API

I retrieve records from an Airtable base and log the ‘Location’ field. How can I adjust my code to log the ‘Size’ field? Using record.get(‘Location’, ‘Size’) did not work.

base('Bins').fetchRecords({
  limit: 3,
  view: 'GridLayout'
}).then(records => {
  records.forEach(item => {
    console.log('Record info:', item.getValue('Location'), item.getValue('Size'));
  });
}).catch(error => {
  console.error('Error fetching records:', error);
});

hey, try checking your field names and use item.getValue(‘Size’) separately. sometimes airtable is picky with casing so make sure its exactly as in the base. hope this helps!

I had a similar issue when trying to log additional fields with Airtable. What worked for me was using the correct method to fetch each field’s value. Instead of trying record.get with multiple arguments, I found that using record.getValue followed by the exact field name did the trick. For example, you should call item.getValue(‘Location’) and item.getValue(‘Size’) separately. This approach ensured that both values were returned properly from the Airtable record without any conflicts.

I encountered a similar problem while integrating the Airtable API into my project. The key is understanding that each field’s value must be accessed individually through its own method call. Attempts to combine field names in a single get or getValue call will not work because the API expects a distinct request for each field. By calling getValue(‘Location’) and getValue(‘Size’) separately, you ensure that each field is retrieved accurately. My experience has shown that adhering to this approach consistently produces reliable and expected results.