Observable Map function not running (Angular2, http)
<p><strong>Update</strong></p>

<p>The issue seems to be that the map function is not run on a "failed" request. This means that if the API I'm talking to returns a <code>422 Validation Failed</code> error (or other 4xx errors) Angular will treat this as a failure and cause the Observer to run the subscribed error callback, skipping the map function in the process.</p>

<p>Is it possible to force Angular to treat certain 4xx errors as successful requests, or force the map function to run even when an Observable returns an error?</p>

<hr>

<p>I have the following code running in my Angular2 app:</p>

<pre><code>import {Injectable} from "angular2/core";
import {Observable} from "rxjs/Rx";
import {Http, Headers, ResponseOptions, Response} from "angular2/http";
import 'rxjs/add/operator/map';

...

public login (email : string, password : string) {
    return this.http.post(_endPoint + '/auth/login/', JSON.stringify({
        email: email,
        password: password
    }), {
        headers: new Headers({
            'Content-Type': 'application/json'
        })
    })
    .map (res =&gt; {
        let data = res.json();
        console.log(data);
        return data;
    });
}
</code></pre>

<p>The code is executing fine, with the exception that the map function is not fired. I am not getting any errors, and have tried running the code both with and without the <code>import 'rxjs/add/operator/map'</code> with the same result. I have also tried a simpler map function <code>.map (res =&gt; res.json());</code>.</p>

<p>In both cases I expect the result returned in the <code>.subscribe()</code> function to be the JSON response, but instead I am getting the raw response.</p>

<p><strong>Edit:</strong> Added a screenshot of the request data, and the response</p>

<p><a href="https://i.stack.imgur.com/juXzI.png" rel="noreferrer"><img src="https://i.stack.imgur.com/juXzI.png" alt="Request details"></a></p>

<p>Response:</p>

<pre><code>[{"field":"email","message":"Email or password incorrect."},{"field":"password","message":"Email or password incorrect."}]
</code></pre>

<p>I've also tested it on a completely successful request (Status Code: 200) and the map function appears to be working fine. So I guess it only runs when a successful response is returned. Is there a way to get it to run regardless, or specify additional status codes that it should run on?</p>