Angular HttpClient “Http failure during parsing”

You can specify that the data to be returned is not JSON using responseType. In your example, you can use a responseType string value of text, like this: return this.http.post( ‘http://10.0.1.19/login’, {email, password}, {responseType: ‘text’}) The full list of options for responseType is: json (the default) text arraybuffer blob See the docs for more information.

Difference between HttpModule and HttpClientModule

Use the HttpClient class from HttpClientModule if you’re using Angular 4.3.x and above: import { HttpClientModule } from ‘@angular/common/http’; @NgModule({ imports: [ BrowserModule, HttpClientModule ], … class MyService() { constructor(http: HttpClient) {…} It’s an upgraded version of http from @angular/http module with the following improvements: Interceptors allow middleware logic to be inserted into the pipeline … Read more

Adding a HTTP header to the Angular HttpClient doesn’t send the header, why?

The instances of the new HttpHeader class are immutable objects. Invoking class methods will return a new instance as result. So basically, you need to do the following: let headers = new HttpHeaders(); headers = headers.set(‘Content-Type’, ‘application/json; charset=utf-8’); or const headers = new HttpHeaders({‘Content-Type’:’application/json; charset=utf-8′}); Update: adding multiple headers let headers = new HttpHeaders(); headers … Read more