This is my code
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
let isAuthenticated: boolean = false
this.authServiceLocal.isAuthenticated().then(response => isAuthenticated = response)
if(isAuthenticated){
return true
}
// not logged in so redirect to login page with the return url
this.router.navigate(['/login'], { queryParams: { returnUrl: state.url }});
return false
}
I want to wait for the response from service then check the value of isAuthenticated I am getting true and false values from server as expected so no problem in api calling.