I am using JavaScript to request Airtable data and need to update the offset parameter when a next-page button is clicked. How can I refresh the API URL dynamically?
let resourceType = "Discounts";
let authToken = "?token=abcd";
let recordLimit = "&limit=10";
let paginationValue = "";
let apiEndpoint = "https://api.airtable.com/v0/app7890/" + resourceType + authToken + recordLimit + "&page=" + paginationValue;
async function fetchRecords() {
const response = await fetch(apiEndpoint);
const result = await response.json();
// Process the result data here
}
function handleNextPage() {
paginationValue = "newPageOffset"; // update to new offset
fetchRecords();
}
document.getElementById('nextBtn').onclick = handleNextPage;