customInterceptor.js
counter = 0;
constructor() {
console.log('interceptor : '+this.counter);
}
log
for login request: example.com/users
interceptor : 0
interceptor : 1
interceptor : 2
interceptor : 3
logout and in again: example.com/users
interceptor : 10
interceptor : 11
interceptor : 12
interceptor : 13
Tried to find out if i have created multiple instances of the interceptor servics, i called this from
app.module.ts
providers: [{
provide: HTTP_INTERCEPTORS,
useClass: customInterceptor,
multi: true,
}],
http.service.ts
counter = 0;
req_counter = 0;
constructor(private injector: Injector) {
console.debug(this.counter++, injector.get(HTTP_INTERCEPTORS);
}
get(url: string, options){
console.debug(req_counter++.concat(' : ', url);
...
}