Skip to main content

Hi, I am trying to use a pagination in my code, but the airtable.js client always returns all results even if pageSize is used. Moreover, if I use pageSize it will query the data from airtable database one page at a time until it reads them all. How to stop this?



I have intercepted the outgoing requests and these are the urls the client calls



GET https://api.airtable.com/v0/applDJB1ThaWVcIJD/Moc%20Data?pageSize=2&maxRecords=5

GET https://api.airtable.com/v0/applDJB1ThaWVcIJD/Moc%20Data?pageSize=2&maxRecords=5&offset=itreHdPlZHyg9RWB3%2FrecBtmAdzmYqi9F8t

GET https://api.airtable.com/v0/applDJB1ThaWVcIJD/Moc%20Data?pageSize=2&maxRecords=5&offset=itreHdPlZHyg9RWB3%2FrecENdiDVazobA9fH



my code:



  async list<T extends TableNames>(baseId: AirtableBaseId, table: T, queryParams?: QueryParams<Tables[t]>): Promise<MetaTable<Tables[t]>[]> {

return this.airtable

.base(baseId)(table)

.select(queryParams) // <- { maxRecords: 5, pageSize:2 }

.all()

.then((r) => { console.debug('r', r); return r })

.then(prettyList)

}



console.debug prints 5 results.



// Edit, I tried it with



      .select(queryParams)

.firstPage()



But it only ever returns the first page without the metadata, such as offset. How do I get the same response I get by calling the endpoint https://api.airtable.com/v0/applDJB1ThaWVcIJD/Moc%20Data?pageSize=2&maxRecords=5 directly from Postman?

Are there any examples implenting pagination in jS?


Reply