Below is the example code from https://airtable.com/api for listing records with Javascript. How should I adjust the code when my base have more than 100 records, and I want to run some code when all the records have been retrieved?
(I know that I’ll have to remove “maxRecords: 3,”)
If I put my code within “eachPage” but then the code will be executed multiple times (obviously).
I’ve tried to put my code in inside an else statement within the done-function but then I don’t have access to the variables and methods like records, record, record.get and so on.
var Airtable = require('airtable');
var base = new Airtable({apiKey: 'YOUR_API_KEY'}).base('appInTsFatECjqsT2');
base('Uppställningsplatser').select({
// Selecting the first 3 records in Alla uppställningsplatser:
maxRecords: 3,
view: "Alla uppställningsplatser"
}).eachPage(function page(records, fetchNextPage) {
// This function (`page`) will get called for each page of records.
records.forEach(function(record) {
console.log('Retrieved', record.get('Uppställningsplats'));
});
// 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.
fetchNextPage();
}, function done(err) {
if (err) { console.error(err); return; }
});