i wanted to exclude some services using interceptor.
app.module.js
providers: [
UserService,
RolesService,
{
provide: HTTP_INTERCEPTORS,
useClass: TokenInterceptor,
multi: true
},
],
Login.service.ts
return this.httpClient.post(this.appUrl + '/oauth/token', body.toString(), { headers, observe: 'response' })
.map((res: Response) => {
const response = res.body;
this.storeToken(response);
return response;
})
.catch((error: any) => {
ErrorLogService.logError(error);
return Observable.throw(new Error(error.status));
});
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…