Hi, I am trying to build a SPA and having an issue with pagination.
From client side, it is calling back-end function to fetch image url of records and pageSize is 16.
What I am hoping to achieve is to fetch every 16 records whenever user clicks ‘show more photos’ and it will fetch another batch of 16 and so on…
but my question is how can I call fetchNextPage() after it fetches the first batch of records and function’s finished. I have little knowledge of callback function and how it works but if you could help me with this, I’d appreciate it.
Here is part of my cloud function
exports = module.exports = functions.https.onRequest(async (req, res) => {
const nextPage= (records, fetchNextPage)=>{
fetchNextPage()
}
const processRecords = (err) => {
console.log('done :>> ');
if (err) {
console.error(err)
return
}
}
_base(tableName).select({
filterByFormula,
fields,
pageSize: 16
}).eachPage(processRecords, nextPage)
});