I have created a custom interface called Table which defines the structure of my data.
export interface Table {
id: number;
title: string;
status: string;
level: string;
description: string;
}
In my service, I am using HttpClient to send a GET request to retrieve data from the backend server.
public tables: Array<Table>;
public getTables(): Observable<Table[]> {
return this.http.get<Table[]>(this.endpoint + 'get-tables');
}
Within my page controller, I am invoking the service function and aiming to convert the JSON response into an array of objects that match the interface 'Table'.
this.tableService.getTables().subscribe((response: Table[]) => {
this.tableService.tables = response;
});
Despite expecting the JSON response to be converted into an array of objects, I am not seeing the desired result in my 'tables' array. Any idea what might be causing this issue?
Your assistance in troubleshooting why the conversion is not occurring as expected would be greatly appreciated.