Update: My apologies to those who answered, it turns out that the code was correct, but requests were being intercepted and losing all parameters.
I am attempting to send repeated HTTP GET requests to a REST API based on the response, using the solution I found in this post.
However, I need to increment one of the parameters in each request. The API paginates the output and requires me to increase the value of startAt
accordingly.
When I manually make the request with:
<URL>/board?startAt=50
I receive:
{"maxResults":50,"startAt":50,"isLast":true,"values":[list_of_values]}
This is my current code:
function getHttpPromise(start_at) {
// This function recursively retrieves values until isLast is true.
test = $http({
url: 'boards',
method: 'GET',
params: {'startAt': start_at.toString()}
}).
success(function (response) {
console.log(response);
var values = response.values;
for (var i in values) {
var board = values[i];
$scope.boards[board.id] = board;
}
if (response.isLast) {
return true;
} else {
start_at += response.maxResults;
return getHttpPromise(start_at);
}
}
);
console.log(test);
return test;
}
This function is invoked by:
jiraWorkLog.controller('SprintSelectCtlr',
function($scope, $http, $routeParams) {
$scope.init = function() {
$scope.boards = new Object();
getHttpPromise(0).then(
function (dummy_var) {
for (var board in $scope.boards) {
...
}
}
);
}
...
);