title: Better way to use guards in Angular
body: <p>I would like to know what is the best way to use the &quot;guards&quot; in Angular to know if a user is logged in. Right now I'm asking if the token is in the Storage. My question is if I could make an endpoint in my API in which a request is made and it answers if the user is authenticated.</p>
  <p>This is my code:</p>
  <pre><code>canActivate(): Promise&lt;boolean&gt; {
      return new Promise(resolve =&gt; {
        this.storageService
          .get(AuthConstants.AUTH)
          .then(res =&gt; {
            if (res) {
              resolve(true);
            } else {
              this.router.navigate(['login']);
              resolve(false);
            }
          })
          .catch(err =&gt; {
            resolve(false);
          });
      });
    }
  </code></pre>