title: How to add HttpClient Interceptors conditionally in Angular
body: <p>Recently I have been using Interceptors with Angular HttpClient.</p>
  
  <p>I add headers corresponding to some HTTP GET methods and for some I do not need those headers.</p>
  
  <p>How can I tell my interceptor to conditionally add interceptors to only those methods? I can even split up services like one service for headers and one without headers or one for different headers and one for different.</p>
  
  <p><strong>NgModule providers</strong></p>
  
  <pre><code>{
    provide: HTTP_INTERCEPTORS,
    useClass: AuthInterceptor,
    multi: true,
  },{
    provide: HTTP_INTERCEPTORS,
    useClass: AngularInterceptor,
    multi: true,
  }
  </code></pre>
  
  <p><strong>MyInterceptors</strong></p>
  
  <pre><code>@Injectable()
  export class AuthInterceptor implements HttpInterceptor {
    intercept(req: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
      const authReq = req.clone({headers: req.headers.set('X-Auth-Token', "-------------------------")});
      return next.handle(authReq);
  
    }
  }
  
  
  @Injectable()
  export class AngularInterceptor implements HttpInterceptor {
    intercept(req: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
      return next.handle(req).do(event =&gt; {}, err =&gt; {
          if(err instanceof HttpErrorResponse){
              console.log("Error Caught By Interceptor");
              //Observable.throw(err);
          }
      });
    }
  }
  </code></pre>