Currently I have 2 functions which call some of my API endpoints. They're setup to take a request followed by a success & failure callback functions. I'm trying to call my DeleteTask function from the success callback of my DeleteTaskUser function. However the DeleteTaskUser function is never firing.
I am pretty new to javascript, trying to build this application as a way to learn it so I could be misunderstanding how to use callbacks in javascript.
Any ideas?
The 2 functions:
this.DeleteTaskUser = function(request, success, failure){
AuthService.resHttp({
method: 'DELETE',
resource: 'DeleteAssignments',
params : request
}).then(
function(res) {
success(res)
},
function(res) {
failure(res)
}
);
}
this.DeleteTask = function(request, success, failure){
AuthService.resHttp({
method: 'DELETE',
resource: 'Task',
data : request
}).then(
function(res) {
success(res)
},
function(res) {
failure(res)
}
);
}
I am trying to call the functions as follows:
for(i = 0; i < $scope.tasksList.length; i++){
TaskApi.DeleteTaskUser(
{
id: $scope.tasksList[i].id,
},
//handle success
function(res){
//This function is never firing, despite the above function succeeding.
console.log("After Task User Deletion");
TaskApi.DeleteTask(
{
id: $scope.tasksList[i].id,
},
function(res){},
function(res){}
)
},
//handle failure
function(res){
console.log(res);
}
)
}