Skip to main content

Confused by API

  • February 21, 2023
  • 1 reply
  • 0 views

Forum|alt.badge.img

Hey all,

I am relatively new to using the Airtable API, and I might just be confused. I am hoping you all can steer me in the right place.

I am used to using APIs to do things, but the Airtable Scripting Api seems weird to me.

To my understanding, when I GET a record, I am only getting the record object with very little fields. Do I need to call getCellValue on all the fields to actually pull out the data or is there a better way to get the data out?

1 reply

Forum|alt.badge.img+6
  • Inspiring
  • 23 replies
  • February 23, 2023

Hey @ilyakoyfman 👋

I'm not sure whether there's any shortcuts aside from iterating over the field names and calling getCellValue

Here's an example that builds an object that maps field names to field values for a given record:

const tableFields = base.getTable("TABLE").fields const rec = await base.getTable('TABLE').selectRecordAsync('RECORD_ID') const allData = tableFields.reduce((acc, field) => { return {...acc, [field.name]: rec?.getCellValue(field.name)} }, {}) console.log(allData)

 


Reply