title: Angular 7 HTTP Interceptor is not working
body: <p>I am new to Angular and I am trying to implement api call which send token in header on all api so I am using Interceptor.</p>
  
  <p>I am not able to set header in request.</p>
  
  <p>jwt.interceptor.ts</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpRequest, HttpHandler, HttpEvent, HttpInterceptor } from '@angular/common/http';
  import { Observable } from 'rxjs';
  
  @Injectable()
  export class JwtInterceptor implements HttpInterceptor {
      constructor() { }
  
      intercept(request: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
  
          let currentUser = localStorage.getItem('useremail')
          let currentUserToken = localStorage.getItem('token')
          if (currentUser &amp;&amp; currentUserToken) {
              request = request.clone({
                  setHeaders: {
                      'Authorization': `${currentUserToken}`
                  }
              });
          }
          // console.log("Request", request)
          return next.handle(request);
      }
  }
  </code></pre>
  
  <p>app.module.ts</p>
  
  <pre><code>import { BrowserModule } from '@angular/platform-browser';
  import { NgModule } from '@angular/core';
  import { AppRoutingModule } from './app-routing.module';
  import { AppComponent } from './app.component';
  import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
  import { AppUserListingComponent } from './app-user-listing/app-user-listing.component';
  import { JwtInterceptor } from './jwt.interceptor';
  
  @NgModule({
    providers: [ { provide: HTTP_INTERCEPTORS, useClass: JwtInterceptor, multi: true } ],
    bootstrap: [AppComponent]
  })
  export class AppModule { }
  </code></pre>
  
  <p>user-listing.service.ts</p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import { HttpClient, HttpHeaders } from '@angular/common/http';
  import { map } from 'rxjs/operators';
  
  @Injectable({
    providedIn: 'root'
  })
  export class UserListingService {
    apiUrl = "URL";
    constructor(
      private http: HttpClient
    ) { }
  
    fetchAllUsers() {
      return this.http.get(`${this.apiUrl}/fetchAdminsUsers`)
    }
  
  }
  </code></pre>
  
  <p>What is the reason my code is not working ? </p>
  
  <p>Thanks in advance</p>