Can you explain how to properly call the next error function using promise chaining?
I initially believed that placing a return statement within the error function would automatically trigger the next error function.
//This code is executed in a controller
dataService.saveRequest()
.then(function success(res){
//This message is logged when the service returns a result
console.log("finished");
}, function failure(error){
//This message should be logged when the service encounters an error, but it's not
console.log("error from controller");
});
//Inside the service function
this.saveRequest = function(){
return $http.post('rest/request/send-request', someData)
.then(function(result){
//The success function in the controller will receive this data as expected
return result.data;
}, function(error){
//However, the following error function is not being triggered
//We need this error function to execute in the controller
return error;
});
};