Help

Welcome to the Airtable Community! If you're new here, check out our Getting Started area to get the most out of your community experience.

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

Topic Labels: API
531 1
cancel
Showing results for 
Search instead for 
Did you mean: 

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 Reply 1

Are there any examples implenting pagination in jS?