Using pagination and offsets Javascript module

Hey all, I am attempting to use the Javascript API to get records in a Node.js server from a base with 10,000+ records. I have used the offset parameter in the past with CURL but am not getting an offset when my query returns. Here is the query at the moment:

    const results = await productsBase('Products').select({
      filterByFormula: `OR(FIND("${BRAND}",{BRAND}),FIND("${PRODUCT}",{PRODUCT}))`,
      maxRecords: maxRecords,
    return await results.all()

Thanks in advance!

Welcome to the Airtable community!

How many records do you expect to get, and what is maxRecords set to?

Hey Kuovonne, I would like it to get 100 records at a time. maxRecords is set to 100 at the moment.

Try increasing maxRecords. The page size determines the number of records per page. Max records determines the total number of records across all pages.

In that case would switching maxRecords to pageSize and using .eachPage instead of .all be the right approach? Somthing like:

const results = await productsBase('Products').select({
  filterByFormula: `OR(FIND("${BRAND}",{BRAND}),FIND("${PRODUCT}",{PRODUCT}))`,
  pageSize: pageSize,
let i = 0
return await results.eachPage(
  function page(records, fetchNextPage) {
    console.log(':~: products.js:fetchProducts records ', records)
    if(i === pageNumber){
      return records
    } else {
  function done(err) {
    if (err) { console.error(err); return; }

If that is the right approach, how do I return the records from the function? My console log is showing that it is itterating correctly but the records are not being returned.

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