Looking for guidance on designing a model in TypeScript to handle the following response:
{
"data":[
{
"name": "XYZ",
"id": "1"
},
{
"name" :"Abc",
"id": "2"
}
]
}
This is what I have tried so far:
export class DataResponse<T>{
data: T;
}
export class MyModel{
name: string;
id: number;
}
What would you recommend for handling situations where all the data will be part of { data: THE_DATA_OBJECT }
?
{
data: []
}
getInfo(): Observable<DataResponse<MyModel[]>> {
// Make API HTTP Call here
}