As a newcomer to angular and API integration, I am facing an issue with ngCharts in my project. The chart specifically requires the keys names in JSON to be "value" and "name", but the API I am using provides keys named "count" and "label". Is there a way for me to change the keys name in my code without modifying the API?
This is how I retrieve data from the API in my service:
getSingleCustomerPurchasesChart(id:number) {
return this.httpClient.get<typeof single>(`${environment.apiUrl}stat/prodaja/${id}`)
}
Here is the model of data required for ngxChart:
export var single: {
value: number;
name: string;
}
And here is what the JSON from the API looks like:
[
{
"count": 123,
"label": "Lorem ipsum",
"id": "42807"
},
]