I just started learning Angular 6 and TypeScript. The backend API call returns data in the following format.
> res = [{
> "metadata": {
> "lastGpSyncTime": "2000-11-21T16:07:53",
> "dataFromDB": true
> },
> "noGoalSelectionReport": {
> "userCount": 0
> },
> "oneGoalSelectionReport": {
> "userCount": 237
> },
> "twoGoalSelectionReport": {
> "userCount": 176
> },
> "threeGoalSelectionReport": {
> "userCount": 17
> },
> "registeredCount": 547 }];
To display this data in a bar chart, it needs to be converted into the required format as shown below.
[{
"goalName": "No Goal",
"userCount": 0
}, {
"goalName": "One Goal",
"userCount": 237
}, {
"goalName": "Two Goals",
"userCount": 176
}, {
"goalName": "Three Goals",
"userCount": 17
}];
Can anyone guide me on how to achieve this conversion using TypeScript?