Hi everyone!
I would like redirect user after 401 response code from interceptor
But when inject Router to custom httpClientWrapper app crash(console empty and blank screen)
Gist with example
thanks
Hi everyone!
I would like redirect user after 401 response code from interceptor
But when inject Router to custom httpClientWrapper app crash(console empty and blank screen)
Gist with example
thanks
Find solution:
…
constructor(http: HttpClient, localStorage: LocalStorageService,
// private _router: Router
@lazy(Router) private _router: () => Router
)
responseError(error) {
if(error.status === 401) {
console.log(‘responseError 401’)
ls.clearUserData();
// TODO: redirect to login page
return router().navigate(‘login’)
}
return error;
}
Can anyone comment on how correct the solution is?