title: Firebase auth TypeError: Cannot read property 'getIdToken' of null
body: <p>I am trying to get the user token using </p>
  
  <pre><code>import { auth, database } from "firebase";
  
  await token = await auth().currentUser.getIdToken();
  </code></pre>
  
  <p>but instead, I am getting this error,</p>
  
  <pre><code>TypeError: Cannot read property 'getIdToken' of null
  </code></pre>
  
  <p>Its sometimes work but sometimes it doesn't. What am I doing wrong here?</p>