title: Angular - LocalStorage empty on start, fills on refresh (F5)
body: <p>I create a simple login form on Angular (v8). On return response, I save it in localStorage like this</p>
  
  <pre><code>this.loginCtrl.login(form.value).subscribe(
       response =&gt; {
            console.log(response["token"]); //IS CORRECT
            if (response["token"] != null) {
                 localStorage.setItem("token", response["token"]);
             }
         })
  </code></pre>
  
  <p>Then I want to get the token and send it to other services.</p>
  
  <pre><code>const httpOptions = {
    headers: new HttpHeaders({
      Authorization: "Token " + localStorage.getItem("token")
    })
  };
  
   getGroupsByEntityAndUser(id: string, user: String) {
      return this.http.get(
        "URL" +
          id +
          "/username/" +
          user,
        httpOptions
      );
    }
  </code></pre>
  
  <p>The problem appears when I load the home page. The console returns that the token is null so the response is null. When I refresh the page with F5 I get the token and <em>getGroupsByEntityAndUser</em> function works properly. It´s a bit strange.</p>
  
  <p>So the question is: Why when I load the first time localStorage is null but when I refresh the page is filled? It is necessary to be filled without refresh.</p>