title: Decoding a JWT token on frontend with atob gives me failed to execute 'atob' on 'window' error
body: <p>On frontend I am checking if my JWT is expired.</p>
  <p>Function is:</p>
  <pre><code>tokenExpired(token: string) {
      const expiry = JSON.parse(window.atob(token.split('.')[1])).exp;
      return Math.floor(new Date().getTime() / 1000) &gt;= expiry;
    }
  </code></pre>
  <p>And then using this function like:</p>
  <pre><code> if (!this.tokenExpired(this.jwtToken || '')) {
        this.getAccountData().subscribe(
          (data) =&gt; {
            this.accout = data;
            this.isLoggedIn();
          },
          (err) =&gt; {
            this.isLoggedIn$.next(2);
          }
        );
      } else {
        this.isLoggedIn$.next(2);
      }
  </code></pre>
  <p>When I build my application it gives me an error in console.log:
  <strong>Failed to execute 'atob' on 'Window': The string to be decoded is not correctly encoded.</strong></p>
  <p>What are some alternatives to use instead of atob or window.atob?</p>
  <p>Thank you!</p>
  <p><strong>SOLVED --&gt; solution:</strong></p>
  <pre><code> tokenExpired(token: string) {
      if (token !== '') {
        const expiry = JSON.parse(atob(token.split('.')[1])).exp;
        return Math.floor(new Date().getTime() / 1000) &gt;= expiry;
      } else {
        return false;
      }
    }
  </code></pre>
  <p>Is this solution a good practice? It doesn't give me an error</p>