title: Sending JWT Token with Angular Service Worker
body: <p>For an Angular 7 app I am developing I'm using a HttpInterceptor to send the token with every request. It looks something like this:</p>
  
  <pre><code>export class JwtInterceptor implements HttpInterceptor {
  intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
      let currentUser = JSON.parse(localStorage.getItem('currentUser'));
      if (currentUser &amp;&amp; currentUser.token) {
          request = request.clone({
              setHeaders: {
                  Authorization: `Bearer ${currentUser.token}`
              }
          });
      }
      return next.handle(request);
  }
  </code></pre>
  
  <p>To turn this app into a progressive web app I am using @angular/service-worker and @angular/pwa. Configuration isn't hard I thought so it looks like it should work. But the problem is I can't find a way to enhance this worker with always sending the token with every request. I know localstorage isn't available in the worker, but that is not the problem right now. I first need to find a way like the HttpInterceptor works now. Is there a standard solution for this problem?</p>