TS2769: No overload matches this call.
The last overload gave the following error.
Argument of type 'HttpHeaders' is not assignable to parameter of type '{ headers?: HttpHeaders | { \[header: string\]: string | string\[\]; } | undefined; context?: HttpContext | undefined; observe?: "body" | undefined; params?: HttpParams | { ...; } | undefined; reportProgress?: boolean | undefined; responseType?: "json" | undefined; withCredentials?: boolean | undefined; }'.
Property 'headers' is private in type 'HttpHeaders' but not in type '{ headers?: HttpHeaders | { \[header: string\]: string | string\[\]; } | undefined; context?: HttpContext | undefined; observe?: "body" | undefined; params?: HttpParams | { ...; } | undefined; reportProgress?: boolean | undefined; responseType?: "json" | undefined; withCredentials?: boolean | undefined; }'.
19 return this.http.post(this.url + 'unique-contacts-reached/', Date, this.httpOptions)
node_modules/@angular/common/http/index.d.ts:2585:5
2585 post\<T\>(url: string, body: any | null, options?: {
\~\~\~\~
The last overload is declared here.
Implementation:
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { throwError } from 'rxjs';
@Injectable({
providedIn: 'root'
})
export class DashboardService {
private httpOptions;
url= 'http://127.0.0.1:8000/dashboard/';
constructor(private http: HttpClient) {
const token = localStorage.getItem('token');
const headers = new HttpHeaders({ 'Content-Type': 'application/json' , 'Authorization' : 'JWT' + ' ' + token});
this.httpOptions = headers;
}
unique_contacts_reached(Date: any){
return this.http.post(this.url + 'unique-contacts-reached/', Date, this.httpOptions)
}
}
The issue arises on this line:
unique_contacts_reached(Date: any){
return this.http.post(this.url + 'unique-contacts-reached/', Date, this.httpOptions)
}