Skip to main content

Airtable.js API _ Getting values as string

  • February 4, 2022
  • 1 reply
  • 9 views

Currently, I load data from my base then individually go through them individually to convert the data to strings. Is there a way to read the data as string when loading?

let people = ;

base(“Employee”)
.select({
view: “Grid view”
})
.eachPage(
function page(records, fetchNextPage) {
records.forEach(function(record) {
let pp = new person();
pp.name = record.get(“Name”);
pp.role = record.get(“Role”);
pp.cards = record.get("(Relevant) Cards");
people.push(pp);
});
fetchNextPage();
},
function done(err) {
if (err) {
console.error(err);
return;
}
}
);

class person {
constructor() {
this.name;
this.role;
this.cards;
}

formatRole(){
if(this.role != null){
let is = ;
for (let i = 0; i < this.role.length; i++) {
base(“Employee”).find(this.role[i], function(err, record) {
if (err) {
console.error(err);
return;
}
is.push(record.fields.Name);
});
}
if(is.length == 1) this.role = is[0];
else this.role = is;
}
}
}

1 reply

kuovonne
Forum|alt.badge.img+29
  • Brainy
  • 6009 replies
  • February 4, 2022

Welcome to the Airtable community!

No, you do not get to choose the format of the data when using the REST API. This is different from using Scripting.