I have a problem with the headers of my request post I want to add a project with name and description but when I try to post my form I have this error:
Argument of type 'RequestOptions' 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'.
And in my console i have this : 401 (Unauthorized)
The code for this (all is good but this part nop) :
addProject(token: string, id: number, nom: string, capteurs): Observable<ProjetModel> {
const headers = new Headers({'X-Auth-Token': token});
const body = { nom, capteurs };
const options = new RequestOptions({ headers: headers });
return this.http.post(`${environment.baseUrl}/projets`, body, options).map((response: Response) => response.json());
}
Thanks,