I have the following error:
If anyone can help me thank you!
I’m sorry for my english but I’m writing for the translator
Argument of type ‘{ headers: Headers; }’ is not assignable to parameter of type ‘{ headers?: HttpHeaders | { [header: string]: string | string[]; }; observe?: “body”; params?: Ht…’.
Types of property ‘headers’ are incompatible.
Type ‘Headers’ is not assignable to type ‘HttpHeaders | { [header: string]: string | string[]; }’.
Type ‘Headers’ is not assignable to type ‘{ [header: string]: string | string[]; }’.
Index signature is missing in type ‘Headers’.
my code
import { HttpClient } from '@angular/common/http';
import { Response, ResponseOptions, Http, Headers} from '@angular/http';
import { Injectable } from '@angular/core';
import 'rxjs/add/operator/map';
@Injectable()
export class ServiceProvider {
api: string = 'http://localhost:8080/api/';
constructor(public http: HttpClient) {
}
getData(){
let headers = new Headers();
headers.append('Content-Type', 'application/json');
return this.http.get(this.api + 'apiRecupera.php').map(res => res )
}
postData(parans){
let headers = new Headers({'Content-Type' : 'application/x-www-form-urlencoded' });
return this.http.post(this.api + "apiCadastro.php", parans, {
headers : headers,
}).map(res => res )
}
}