title: Angular 6 get request custom param in http interceptor
body: <p>I'm trying to retrieve a custom param from http request in an interceptor. I need this to show or not an error message.
  I set a custom param in this way:</p>
  
  <pre><code>getTickets(): Observable&lt;Ticket&gt; {
      var params = new HttpParams();
      params.append('showErrorMessage', 'false'); 
      return this.http.get(Conf.BaseUrl + 'tickets', { params: params });
  }
  </code></pre>
  
  <p>And I try to get the param in my interceptor:</p>
  
  <pre><code>intercept(req: HttpRequest&lt;any&gt;, next: HttpHandler): Observable&lt;HttpEvent&lt;any&gt;&gt; {
      return next.handle(req).pipe(
          tap(
              (event: HttpEvent&lt;any&gt;) =&gt; {
                 let show = req.params.get('showErrorMessage');
                 ...
              }
           )
      )
  }
  </code></pre>
  
  <p>In req.params there isn't my custom param, so I think this isn't the correct way to set and get request params.
  Any suggestions?
  Thanks</p>
  
  <p><strong>EDIT:</strong>
  To avoid confusion I change my question, I hope to be clearer.
  I should set a param calling a service method and make interceptor able to get this param. Is there a way to do this? Is it possible to 'pass' a parameter from service to interceptor during an http request?
  I tried to use HttpHeaders and HttpParams but it doesn't work. </p>
  
  <p><strong>SOLVED</strong>
  I found a solution. I don't know the reason but using params variable as HttpParams doesn't work. Instead in this way it works:</p>
  
  <pre><code>getTickets(): Observable&lt;Ticket&gt; {
      return this.http.get(Conf.BaseUrl + 'tickets', {
          headers: {
              showErrorMessage: 'false'
          });
  }
  </code></pre>
  
  <p>and in interceptor:</p>
  
  <pre><code>...
      tap(
          (event: HttpEvent&lt;any&gt;) =&gt; {
              let show = req.headers.get('showErrorMessage');
                 ...
          }
      )
  ...
  </code></pre>
  
  <p>I get the value setted in http request.</p>