Type 'Headers' has no properties in common with type 'RequestOptionsArgs'? Type 'Headers' has no properties in common with type 'RequestOptionsArgs'? angular angular

Type 'Headers' has no properties in common with type 'RequestOptionsArgs'?


Update for 4.3 HttpClient

The new syntax to be compatible with HttpClient, introduced in angular 4.3, is:

import { HttpClient, HttpHeaders } from "@angular/common/http";private _options = { headers: new HttpHeaders({ 'Content-Type': 'application/json' }) };

No more RequestOptions: parameters are added using the new immutable HttpParams Map.

Pre 4.3 / Http

I just noticed that RequestOptions now requires you to explicitly pass named options as an object, like:

headers: Headers = new Headers({ 'Content-Type': 'application/json' });options: RequestOptions = new RequestOptions({ headers: this.headers });