title: Using httpOptions in Angular 7 http.get method changes result type
body: <p>I'm somewhat new to Angular. I just want to load some products from an API and then create instances of my class (not just objects 'shaped' to my class). So I have a constructor on my Product class that will copy the incoming values.</p>
  
  <p>Here's my method in the service class, which works fine.</p>
  
  <pre><code>getProductList(): Observable&lt;Product[]&gt; {
      return this.http
          .get&lt;Product[]&gt;(this.productListUrl)
          .pipe(
              map(data =&gt; data.map(item =&gt; new Product(item))),
              catchError(this.handleError));
  }
  </code></pre>
  
  <p>However, I also want to pass a token in the GET request header for authentication. So I'm adding an httpOptions object to the get method call (with an Authorization key/value set in the httpOptions):</p>
  
  <pre><code>@Injectable()
  export class ProductService {
  
  // http options used for making API calls
  private httpOptions: any;
  
  private apiURL = environment.apiURL;
  private productListUrl = this.apiURL + '/api/v1/products/';
  
  constructor(private http: HttpClient) {
      this.httpOptions = {
          headers: new HttpHeaders({'Content-Type': 'application/json'}),
          observe: 'events'
      };
  }
  
  getProductList(): Observable&lt;Product[]&gt; {
      return this.http
          .get&lt;Product[]&gt;(this.productListUrl, this.httpOptions)
          .pipe(
              map(data =&gt; data.map(item =&gt; new Product(item))),
              catchError(this.handleError));
  }
  
  private handleError(res: HttpErrorResponse | any) {
      console.error(res.error || res.body.error);
      return observableThrowError(res.error || 'Server error');
  }
  }
  </code></pre>
  
  <p>But somehow the addition of the httpOptions argument to the get method causes the return type to change, and the compile now complains <code>Property 'map' does not exist on type 'HttpEvent&lt;Product[]&gt;'.</code> and won't compile.</p>
  
  <p>Any thoughts on whether I'm doing this wrong, or how I would change the way I'm using map? Thanks!</p>