the api returns the total number of items, which you can use to keep track of your count.
var currentCount = 0;
var cursor = ''
do {
// send request
for (var i = 0; i < response.data.length; i++) {
// do work
currentCount += 1;
cursor = response. pagination.cursor;
}
while (currentCount < response.total)