Basically I want to extract only the fields property from each item and ignore all the metadata stuff. I think I should use the map function but I’m not sure how to handle nested objects like this.
I destructure right in the map function with Airtable responses. const result = data.map(({ fields }) => fields) works great. Watch out though - Airtable sometimes returns records where field values are undefined or completely missing. I add basic validation when I’m expecting specific properties. You can also use optional chaining like data.map(item => item.fields || {}) to prevent crashes if the structure changes. The nested metadata is annoying but it’s consistent across their API, so cleanup’s pretty straightforward once you know the pattern.
You can also transform fields during mapping if needed. I’ve hit issues where Airtable field names had spaces or special characters that broke my frontend components. Something like data.map(item => ({ title: item.fields.Title, uniqueId: item.fields.UniqueID })) lets you rename properties while extracting. Also helpful to grab the record ID for later updates - data.map(item => ({ id: item.id, ...item.fields })) keeps the Airtable record ID with your clean field data. The spread operator keeps it clean and you’ve got the reference back to Airtable for record modifications.