Airtable.js always returns all results even if pageSize is used

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?

1 Like

Are there any examples implenting pagination in jS?

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.