
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 12, 2021 03:21 PM
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!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 12, 2021 05:28 PM
Welcome to the Airtable community!
How many records do you expect to get, and what is maxRecords set to?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 13, 2021 08:28 AM
Hey Kuovonne, I would like it to get 100 records at a time. maxRecords is set to 100 at the moment.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 13, 2021 08:46 AM
Try increasing maxRecords. The page size determines the number of records per page. Max records determines the total number of records across all pages.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Aug 13, 2021 09:18 AM
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 {
i++
fetchNextPage()
}
},
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.
