title: Angular http client observable pipe map
body: <p>I have this in my service</p>
  
  <pre><code>  doSomething(): Observable&lt;any&gt; {
      return this.http.get('http://my.api.com/something')
        .pipe(
          map((data: Response) =&gt; {
              if (data &amp;&amp; data['success'] &amp;&amp; data['success'] === true) {
                return true;
              } else {
                return false;
              }
            }
          )
        );  
    }  
  </code></pre>
  
  <p>This works, I can subscribe to the function from my component , for example</p>
  
  <pre><code>    this.myService.doSomething().subscribe(
          (result) =&gt; {
              console.log(result);
          },
          (err) =&gt; {
              console.log("ERROR!!!");
          }
      );
  </code></pre>
  
  <p>Al this already works, but I want to refactor so that I can remove </p>
  
  <pre><code> if (data &amp;&amp; data['success'] &amp;&amp; data['success'] === true)
  </code></pre>
  
  <p>in my map. So that the map function only will be executed when I have upfront did the check. My first thought was to add a function in the pipe stack that will take the Response from the http client, check if the the conditions are good, otherwise throw an error (with throwError function). But I'm strugglin how to (well at least figure out wich Rxjs function to use). </p>
  
  <p>Can somebody help me out with this?</p>