@riyu wrote:
I have a lot of http promise and I used the http interceptor to put a loading screen in all my http. I based it on the ionic turoials. I just added requestError and responseError so that it doesn't load infinitely if the http has a response error. And it works.
.config(function($httpProvider) {
$httpProvider.interceptors.push(function($rootScope, Utilities) {
return {
request: function(config) {
$rootScope.$broadcast('loading:show');
return config;
},
response: function(response) {
$rootScope.$broadcast('loading:hide');
return response;
},
requestError: function(config) {
$rootScope.$broadcast('loading:hide');
return config;
},
responseError: function(response) {
$rootScope.$broadcast('loading:hide');
return response;
}
};
});
})Now for my problem. After implementing the http interceptors, my promises don't ever go to the function(err) part of my code anymore. They always go to the function after the then. I think it is because the http intercepted all errors. Is there another way for both codes to work?
Exams.getUserAnswered(examObj).query().$promise.then(function(queryUserAnswered) {
console.log("data: "+JSON.stringify(queryUserAnswered));
},function(err){
//handle error
console.log("getUserAnswered error");
});
Posts: 1
Participants: 1