In python it is possible to do this with a "while loop":
#start with an empty list
all_records_list = []
# while there is at least one record on a page, get each page and append it to the all_records_list
while len(records_on_page) > 1:
url = 'https://***.caspio.com/rest/v2/tables/***/records?q.pageSize=1000&q.pageNumber='+ str(i)
response = requests.get(url,headers=headers)
response_dictionary = response.json()
records_on_page = response_dictionary['Result']
all_records_list.extend(records_on_page)
# for clarity, print what page number we are on and how many records we have so far
print("Page number "+ str(i))
print(len(all_records_list))
i += 1
Unfortunately Python is my strongest language, so I can only offer help in that regard. But I am sure there is a way to do the same in Javascript with a loop also!