title: JavaScript interop Error when calling javascript from OnInitializedAsync Blazor
body: <p>I am following a sample app from the NDC Oslo which is this app: <a href="https://github.com/SteveSandersonMS/presentation-2019-06-NDCOslo/tree/master/demos/MissionControl" rel="noreferrer">https://github.com/SteveSandersonMS/presentation-2019-06-NDCOslo/tree/master/demos/MissionControl</a>.
  This implements JWT as authentication and authorization. However when I tried to copy the implementation of the code to a Server Side Blazor, I'm getting an error when I try to get the JWT token stored from the local storage described below"</p>
  
  <pre><code>JavaScript interop calls cannot be issued at this time. This is because the component is being 
  statically rendererd. When prerendering is enabled, JavaScript interop calls can only be performed 
  during the OnAfterRenderAsync lifecycle method.
  </code></pre>
  
  <p><strong>Here is my blazor code</strong></p>
  
  <pre><code>protected override async Task OnInitializedAsync()
  {
      var token = await TokenProvider.GetTokenAsync();
      Branches = await Http.GetJsonAsync&lt;List&lt;BranchDto&gt;&gt;(
          "vip/api/lookup/getbranches",
          new AuthenticationHeaderValue("Bearer", token));
  }
  </code></pre>
  
  <p><strong>The error comes from</strong></p>
  
  <pre><code>public async Task&lt;string&gt; GetTokenAsync()
  {
     //Code Omitted for brevity 
     //This line of code is equivalent to the IJSRuntime.Invoke&lt;string&gt;("localstorage.getitem","authToken") 
     //change to use Blazore.LocalStorage.
      var token = await _localStorageService.GetItemAsync&lt;string&gt;("authToken");
      return token;
   }
  </code></pre>
  
  <p>I tried perform the code on <strong>OnAfterRenderAsync(bool firstRender)</strong> and the error is gone but the grid which is binded to the API request has no display. The API request must fill the data source for the grid which must be <strong>OnInitializedAsync</strong>. Any workaround on this?</p>
  
  <p><strong>Update!</strong>
  I moved the code OnAfterRenderAsync and added the StateHasChanged Method and I got the desired Behavior.
  I forgot that the connection for rendering was a signalR connection. </p>