I´m creating a Phonegap Application with angular js and Ionic framework. This application uses http requests to a server and i need to inject some parameters in each http request. For this topic i´m trying to use a service called authInterceptor (which i have used before in a web application and works perfectly) that have to intercept all http requests but this service is not working in the mobile. I´m not sure if i have to do something different in a phonegap application. This is my service:
.factory('AuthInterceptor', function($q, $location, AuthToken) {
var interceptorFactory = {};
// this will happen on all HTTP requests
interceptorFactory.request = function(config) {
if (condition)
//inject the parameters
return config;
};
// happens on response errors
interceptorFactory.responseError = function(response) {
// if our server returns a 403 forbidden response
if (response.status == 403){
}
// return the errors from the server as a promise
return $q.reject(response);
};
return interceptorFactory;
});
I hope someone can help me with this problem. Thanks a lot