I have a service from which I want to access data which are in this form from an HTTP GET request:
"data": [
{
"id": "432",
"Time": "06:25",
"Place": "Atalanta"
},
{
"id": "581",
"Time": "18:21",
"Place": "Georgia"
}
]
I've created a service to call it which does this return method
return this.http.get<DataGroup>(url);
and two class models to access those data:
import { DataGroupValue } from './DataGroupValue';
export class DataGroup{
value: DataGroupValue[] = [];
}
(don't know if it's doing the job right though)
export class DataGroupValue {
id: string;
Time: string;
Place: string;
}
and a component that tries to call this method which doesn't work
export class TestPlannerComponent implements OnInit {
DataGroupValues = new Array<DataGroup>();
constructor(private dataService: DataService ) { }
ngOnInit(): void {
this.dataService.GetDataGroup.subscribe((res:DataGroup))=>{
this.DataGroupValues=res; //errors here
}
}
}
How can we access those values?