0

I use angular9, rxjs6 and implement canActive: Observable
But I got an error when use catchError, like this:

enter image description here

How can I fix this?

I tried update to: but it still not work. enter image description here

ThuyNguyen
  • 1,127
  • 3
  • 14
  • 24

1 Answers1

0

another way to solve canActivate function in your guard is only use subscribe because i think use map in this situation is wrong

  this.yourService.subscribe(
    (r) => {
      //your code
      return true;
    },
    (error: any) => {
      return false;
    }
  );
mehranmb78
  • 674
  • 5
  • 9
  • my function need return Observable to waiting check – ThuyNguyen Jan 05 '21 at 06:52
  • my friend you can add another type to your canActivate function to cover boolean response because in your situation problem is solved by boolean like this one: canActivate( route: ActivatedRouteSnapshot, state: RouterStateSnapshot ): Observable | Promise | boolean – mehranmb78 Jan 05 '21 at 07:08