How to fetch multiple field values using Airtable API

I’m working with an Airtable database and can successfully pull records using their API. Right now my code only shows data from one column called “Location”. I want to also display values from another column named “Size” at the same time.

Currently I’m using console.log('Found: ', record.get('Location')); to show the Location data. I tried changing it to console.log('Found: ', record.get('Location', 'Size')); but that approach failed.

My current code looks like this:

// Fetch 3 records from Products table
base('Products').select({
    maxRecords: 3,
    view: "Main view"
}).eachPage(function page(entries, fetchNextPage) {
    entries.forEach(function(entry) {
        console.log('Found: ', entry.get('Location'));
    });
    
    fetchNextPage();
}, function done(error) {
    if (error) { console.error(error); return; }
});

Current output shows:

Found 170000118

Found 170000119

Found 170000120

What’s the right way to get both Location and Size field values in the same output?

record.get() only takes one field name at a time. You’ve got to call it separately for each field.

Here’s the fix:

base('Products').select({
    maxRecords: 3,
    view: "Main view"
}).eachPage(function page(entries, fetchNextPage) {
    entries.forEach(function(entry) {
        const location = entry.get('Location');
        const size = entry.get('Size');
        console.log('Found: Location =', location, ', Size =', size);
    });
    
    fetchNextPage();
}, function done(error) {
    if (error) { console.error(error); return; }
});

I’ve hit this same problem tons of times building data sync tools. Just grab each field value into its own variable first, then combine them however you want.

Template literals work great for cleaner output:

console.log(`Found: ${entry.get('Location')} - Size: ${entry.get('Size')}`);

New to Airtable’s API? This tutorial’s solid:

Pro tip - if you need lots of fields from the same record, use entry.fields to grab everything at once and pick what you want.