I add errorHandlerInterceptor
to handle errors as you seen below:
(function() {
'use strict';
angular
.module('rasool')
.config(httpConfig);
function httpConfig($httpProvider) {
$httpProvider.interceptors.push('errorHandlerInterceptor');
}
})();
and in the errorHandlerInterceptor
i want to get a specific header from response headers like this:
(function() {
'use strict';
angular
.module('rasool')
.factory('errorHandlerInterceptor', errorHandlerInterceptor);
function errorHandlerInterceptor ($q, toaster, $rootScope, $timeout) {
var service = {
responseError: responseError
};
return service;
function responseError (response) {
var errorHeader = response.headers('X-app-alert');
if(errorHeader) {
// do something
}
return $q.reject(response);
}
}
})();
The problem is that the errorHeader
is null, but when i check the response headers with Chrome DevTools, this header exists and have a value as you can see in the below screenshot:
UPDATE
All of these part are running correctly in the website, but i created a copy of html, js and css files to create an ionic1 application, but when i run ionic serve
command to test the application, i have this problem.