When trying to loop through a JSON object returned from a GET request, I encountered an error saying: Property 'forEach' does not exist on type 'Employee'. The Employee type is an observable.
This issue arises in Angular 7.
employee: Employee[];
single: any = [
{
"name": [],
"value": []
}
];
chartData(id){
return this.employeeService.getEmpSkill(id)
.subscribe( data => data.forEach((i) => {this.single.push({name: (i.skill_name), value: (i.score) })
this.single = [...this.single]
console.log(this.single)
}));
}
https://i.sstatic.net/WyYEA.png
My goal was to receive an array for chart data, but instead, I received the following error: error TS2339: Property 'forEach' does not exist on type 'Employee'.