Issue - My task involves consolidating the response array into one. I am making consecutive calls to the same API, with a dynamic 'skip' parameter based on the last response.
Call #1 - api(id, skip=0)
Call #2 - api(id, skip+1)
...
Below is the implementation:
function combineArrays(jobId, skip, count) {
appSegmentService.csvDownload(jobId, skip, count)
.then(function(resp) {
var finalArray = [];
finalArray = finalArray.concat(resp.data);
skip += 5000;
if (resp.data.length === 5000) {
finalArray = finalArray.concat(combineArrays(jobId, skip, count));
} else {
console.log(finalArray);
}
}, function(err) {
console.error(err);
});
}