I have an api that returns ISO date that needs to be transformed into javascript date. I am using the HTTPClient module that does the mapping automatically but it seems it is not transforming the data received.
I know that it works if I do it using the http module but I want to use the HTTPClient.
My Code is below.
export class Product{
datetime: string;
qty: number;
constructor(date: string, hr: number ) {
this.datetime = new Date(Date.parse(date));
this.heartrate = hr;
}
}
@Injectable()
export class BandHeartRate {
private Url = 'http://192.168.1.1:6000';
constructor(private http: HttpClient) {}
public getProduct(): Observable<Product[]> {
return this.http.get<Product[]>(`${this.Url}/web/api/v2/product`,
{headers: this.getHeader()});
}
private getHeader() {
const header = new HttpHeaders();
header.append('Accept' , 'application/json');
return header;
}
}
}
getProduct()? Where are you calling yourProductclass?