Published
Edited
Mar 30, 2022
Importers
13 stars
Insert cell
Insert cell
Inputs.table(getAirtable("Furniture"))
Insert cell
baseId = 'appJFrP4uCCmauTwm'
Insert cell
apiKey = 'keyIc18GDipgCIM21'
Insert cell
base = airtable.base(baseId)
Insert cell
async function getAirtable(table, selectOptions = {}) {
const data = (await base(table).select(selectOptions).all()).map(
(d) => d.fields
);
data.columns = Array.from(new Set(data.flatMap((d) => Object.keys(d))));
return data;
}
Insert cell
Insert cell
function getAirtableByPages(
table,
{ incremental = true, selectOptions = {}, columns } = {}
) {
return Generators.observe((next) => {
const data = [];
base(table)
.select(selectOptions)
.eachPage(
async function page(records, fetchNextPage) {
// This function (`page`) will get called for each page of records.
for (const r of records) data.push(r.fields);
if (columns === undefined) {
data.columns = columns = Array.from(
new Set(data.flatMap((d) => Object.keys(d)))
);
}
if (incremental) next(data);
// To fetch the next page of records, call `fetchNextPage`.
// If there are more records, `page` will get called again.
// If there are no more records, `done` will get called.
await Promises.delay(200); // No more than 5 queries per second
fetchNextPage();
},
function done(err) {
if (err) {
console.error(err);
return;
}
next(data);
}
);
next(data);
});
}
Insert cell
airtable = import("https://cdn.skypack.dev/airtable@0.11.2?min").then(
(airtable) => (
airtable.configure({
endpointUrl: "https://api.airtable.com",
apiKey
}),
airtable
)
)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more