I am building and AngularJS app using ES6 classes with traceur transpiling to ES5 in AMD format.
in my module I import the interceptor class and register it as a service
This is exactly the same problem I'm experiencing, however, I found a workaround by setting the 'this' in a self variable just like solving the scoping issue on es5, and it works fine:
let self;
class AuthInterceptor{
constructor(session){
self = this;
this.session = session;
}
request(config){
if(self.session) {
config.headers = self.session.getSessionParams().headers;
}
return config;
}
responseError(rejection){
if(rejection.status == 401){
}
return rejection;
}
}
export default AuthInterceptor;