I'm trying to get the resolved promise object after aborting a REST call (using {timeout: canceller.promise}), but I'm unable to get the resolved promise object.
factory:
angular.module('RestModule').factory('abc', function ($http, $rootScope) {
var canceller = $q.defer();
$rootScope.$on('CANCEL_REQUESTS', function () {
canceller.resolve({'isAborted': true});
});
return {
getDetails: function() {
return $http.get('/test/testREST', {timeout: canceller.promise}).then(function (data) {
return httpData.data;
});
}
});
controller:
.controller('testCtrl', function (abc, $rootScope) {
abc.getDetails().then(function (data) {
// success call back
}, function (error) {
console.log(error.isAborted);
});
$rootScope.$emit('CANCEL_REQUESTS');
});
Here in the error call back I'm not getting the timeout promise object (isAborted: true). error.isAborted is undefined.
canceller.rejectinstead ofcanceller.resolve, if you're expecting that result in the error handler function?