I'm trying to create a variable to set one of the properties of an object obtained by the get method.
When I give console in subscribe I retrieve the value of the array, but I'm having difficulty (i'm beginner) to set only one of the properties of the objects in that array.
Component:
this.mainService.getGraph()
.subscribe(res => {
console.log(res)
this.name = res[''].map(res => res.name)
console.log(this.name)
Console.log:
(5) […]
0: Object { name: "Carlos", lastname: "Moura", participation: 5 }
1: Object { name: "Fernanda", lastname: "Oliveira", participation: 15 }
2: Object { name: "Hugo", lastname: "Silva", participation: 20 }
3: Object { name: "Eliza", lastname: "Souza", participation: 20 }
4: Object { name: "Anderson", lastname: "Santos", participation: 40 }
length: 5
<prototype>: Array []
main.component.ts:26:6
ERROR TypeError: "res[''] is undefined"
ngOnInit main.component.ts:27
RxJS 13
Angular 8
this.name = res[0].name;? <= assign the component's fieldnameto the fieldnameof the first object in the returned array.