i write below code as my main page guard that use checkTokenValidation()
to valid authentication token from user but my IDE show this error :A function whose declar
By subscribing you are returning a Subscription
instead of an Observable
.
You should map to the desired values and return an Observable
:
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable | Promise | boolean {
return this.authService.checkTokenValidation().pipe(
map( (data) => {
if (data['ok']) {
this.router.navigate(['/overview']);
return false;
} else {
return true;
}
})
);
}