I have below script for Angular promise
.I have chained finally method
with then
bale.But some time I am getting error TypeError: Cannot call method 'finally' of undefined
.
Here is the script :
someSerivces.getSomeMethod(someData)
.then(
function(data) {
//success
},
function(error) {
// rejection
}
).finally(function() {
//script
});
GetSomeMethod :
someSerivces.getSomeMethod = function() {
var deferred = $q.defer();
otherService.httpCall({...})
.then(
function(response) {
deferred.resolve(response.data);
},
function(response) {
deferred.reject(response);
}
);
return deferred.promise;
};
I know its because of promise is not available for chaining.So,it getting such error.How I can hanlded this error ? Or is there any other way to handled it?
How I can handled this exception?