title: Angular 7 switchMap calling Twice
body: <p>I have been trying to get this to work with just one request. </p>
  
  <p>But when the function calls the service it fires the get request twice.</p>
  
  <p>If I remove the switchMap it fires once. </p>
  
  <p>The http request is fired twice it should only fire once.</p>
  
  <p>Any help is appreciated!</p>
  
  <pre><code>loadReports(val: {}) {
  
    const modelCode = val['modelCode'];
  
    this._reportService.getReportTypes(modelCode).pipe(
      debounceTime(200),
      distinctUntilChanged(),
      switchMap(() =&gt; this._reportService.getReportTypes(modelCode)),
      share(),
    ).subscribe(
      (data) =&gt; {
        console.log(data);
      },
      (error) =&gt; {
     ...
      },
      () =&gt; {
      ...
      }
    );
  
  }
  </code></pre>
  
  <p>here is the service    </p>
  
  <pre><code>getReportTypes(modelCode: string): Observable&lt;any&gt; { 
  ...
      return this._http.get(apiUrl, httpOptions).pipe(
        tap( _ =&gt; console.log('fetched product types')),
        map((resp: Response) =&gt; {
        // return data;
            return resp.body['data'].map((item: any[]) =&gt; this._adapter.adapt(item));
        }),
        catchError(this.handleError&lt;any&gt;('getReportTypes Error', []))
      );
  }
  </code></pre>
  
  <p>Thanks
  For your help</p>