I've been exploring a new authentication approach detailed in this article.
One issue I'm encountering is locating where the req
parameter is declared in the snippet below. It seems like my code won't compile because this parameter isn't explicitly defined. There's a chance that it might be a mistake in the original code provided. I scanned through the comments but nobody seems to have mentioned this:
// src/app/auth/jwt.interceptor.ts
// ...
import 'rxjs/add/operator/do';
export class JwtInterceptor implements HttpInterceptor {
constructor(public auth: AuthService) {}
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(req).do((event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
// perform actions on response, if needed
}
}, (err: any) => {
if (err instanceof HttpErrorResponse) {
if (err.status === 401) {
// redirect user to login page
// or display a modal
}
}
});
}
}"
Could someone offer insight into what might be causing my problem?
Thank you kindly in advance.