i dont find this awnser in the documentation (angular and rxjs), when I make a HttpCliente request in angular an return an observable, example:
let request = this.http.get(url);
request.subscribe(
{
next: data => console.log(data),
error: error => console.log(data)
}
);
the doubt: only will 'fall' into the next if the request answer is 200? any other as 403, 400, 201, etc will 'fall' into error?
2xx
codes are consider valid and will emit a next
notification.
Any other code will throw an Error
.
Following code is extracted from the HttpXhrBackend
implementation. Full code
...
// ok determines whether the response will be transmitted on the event or
// error channel. Unsuccessful status codes (not 2xx) will always be errors,
// but a successful status code can still result in an error if the user
// asked for JSON data and the body cannot be parsed as such.
let ok = status >= 200 && status < 300;
...
Cheers
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments