I want to create a httpRequestInterceptor to use in .config of application.
>
> $httpProvider.interceptors.push('httpRequestInterceptor');
I have this provider and factory of RequestInterceptor:
angular.module('app.services', [])
.provider('appProvider', [function () {
var apiUrl = "http://url/api";
var _authToken = null;
var _currentUser = null;
this.$get = function($q, $http, $cookieStore) {
var service = {
getAuthToken: function() {
return _authToken ?
$cookieStore.get('authToken') ?
(_authToken = $cookieStore.get('authToken'),
_authToken) :
'' : _authToken;
}
};
return service
}
}])
.factory('httpRequestInterceptor', [function () {
return {
request: function(config) {
config.headers = {'auth-toke': appProvider.getAuthToken()}
return config;
}
};
}]);
I get error: Cannot read property 'getAuthToken' of undefined
How to fix this issue?
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.