title: How can I let my if statement wait for get request to complete ( GUARD ) using angular
body: <p>I want to create admin routes for my angular app. I've created a role guard in angular. See my code below.</p>
  
  <p>Now I want my get request to complete before my if statement starts checking if the user is an admin. Is there a way to do this?</p>
  
  <pre><code>export class RoleGuardGuard implements CanActivate {
  
    public user;
  
    constructor( private apiService: ApiService ) {}
  
    canActivate(
      next: ActivatedRouteSnapshot,
      state: RouterStateSnapshot): Observable&lt;boolean | UrlTree&gt; | Promise&lt;boolean | UrlTree&gt; | boolean | UrlTree {
  
        this.apiService.getUserAdminData().subscribe((data)=&gt;{
          this.user = data;
        });
  
        if (this.user.user_role === 'admin') {
          return true;
        } else {
          return false;
        }
    }
  
  </code></pre>