title: Merge two observables in angular for CSV to JSON conversion
body: <p>I have a <code>csv</code> file and I want to conver it into a <code>JSON</code>.</p>
  <p>I' m reading the CSV file with <code>HttpClient</code> and then I'm using <a href="https://github.com/Keyang/node-csvtojson" rel="nofollow noreferrer">csvToJson</a> to convert it.</p>
  <p>This test code works:</p>
  <pre class="lang-js prettyprint-override"><code>this.httpClient
        .get('assets/csv/results.csv', { responseType: 'text' })
        .subscribe(
          (data) =&gt; {
            csv()
              .fromString(data)
              .subscribe((jsonObj) =&gt; console.log(jsonObj));
          }
        );
  </code></pre>
  <p>But when I try to merge the two observables to create a function:</p>
  <pre class="lang-js prettyprint-override"><code>
    convert() {
      this.httpClient
        .get('assets/csv/results.csv', { responseType: 'text' })
        .pipe(switchMap((d) =&gt; csv().fromString(d)))
        .subscribe((c) =&gt; console.dir(c));
    }
  </code></pre>
  <p>I get this error:</p>
  <pre><code>core.js:4352 ERROR TypeError: You provided an invalid object where a stream was expected. You can provide an Observable, Promise, Array, or Iterable.
      at subscribeTo (subscribeTo.js:27)
      at innerSubscribe (innerSubscribe.js:69)
      at SwitchMapSubscriber._innerSub (switchMap.js:44)
      at SwitchMapSubscriber._next (switchMap.js:34)
      at SwitchMapSubscriber.next (Subscriber.js:49)
      at MapSubscriber._next (map.js:35)
      at MapSubscriber.next (Subscriber.js:49)
      at FilterSubscriber._next (filter.js:33)
      at FilterSubscriber.next (Subscriber.js:49)
      at MergeMapSubscriber.notifyNext (mergeMap.js:70)
      at SimpleInnerSubscriber._next (innerSubscribe.js:10)
      at SimpleInnerSubscriber.next (Subscriber.js:49)
      at XMLHttpRequest.onLoad (http.js:1678)
      at ZoneDelegate.invokeTask (zone-evergreen.js:399)
      at Object.onInvokeTask (core.js:27474)
      at ZoneDelegate.invokeTask (zone-evergreen.js:398)
  </code></pre>
  <h3>Update</h3>
  <p>I've created a <a href="https://stackblitz.com/edit/angular-ivy-2ksumy?devtoolsheight=33&amp;file=src/app/csv-2-json.service.ts" rel="nofollow noreferrer">stackblitz</a> to experiment.</p>
  <p>In the stackblitz I get an error I don't get on localhost:</p>
  <pre class="lang-js prettyprint-override"><code>Error in src/app/csv-2-json.service.ts (18:24)
  This expression is not callable.
  Type '{ default: (param?: Partial&lt;CSVParseParam&gt;, options?: any) =&gt; Converter; }' has no call signatures.
  </code></pre>
  <p>In the library <a href="https://github.com/Keyang/node-csvtojson" rel="nofollow noreferrer">source code</a> I see that the <code>fromString()</code> returns a <a href="https://github.com/Keyang/node-csvtojson/blob/master/src/Converter.ts" rel="nofollow noreferrer">Converter</a> that implements <code>PromiseLike&lt;any[]&gt;</code> so I thought it should work.</p>
  <p>What I'm doing wrong?</p>