Я пытаюсь использовать canActivate
(который я использовал в течение последних 2 лет) на angular 8, и я не могу заставить его работать.
на обновление / f5 Я не ' я даже не вижу запрос в сети, и когда он входит внутрь ответа, он выдает мне «не могу прочитать длину свойства undefined»
Вот код:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
const user = this.cookieSerivce.getUserCookie();
if (!this.userService.getUserIfExists().Authorization && user) {
this.userService.setUser(user);
}
return this.usersEndpointService.validateUserToken().pipe(
map((res) => {
if (!res.code) return true;
this.wrongToken();
return false;
},
}));
}
const routes: Routes = [
{path: '', component: LoginComponent},
{path: 'forgot-password', component: ForgotPasswordComponent},
{path: 'reset-password', component: ResetPasswordComponent},
{path: 'dashboard', component: DashboardComponent, canActivate: [ValidTokenService]},
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule]
})
export class AppRoutingModule { }
Что я отсутствует? Я точно знаю, что он даже не отправляет запрос, не видит его в сети и не получает на бэкэнде, почему?