When my API sends back a JSON response, my Angular application is able to capture it using an Interface. The structure of the JSON response appears as follows:
{
"release_date":"2012-03-14",
"genre_relation":[
{
"id":"2604ebbf-4eb5-46e3-89d8-ab4e8ecc8275",
"name":"ABC"
},
{
"id":"5267a0c6-9423-4e28-a413-133cc3435612",
"name":"DEF"
},
{
"id":"13d1454a-fc0e-457c-9f8e-9a9952984d8c",
"name":"GHI"
}
]
}
I am wondering how I can access the nested 'name' field in the response data. If I try referencing it like this in my template:
<p>{{ api_response.genre_relation.name }}</p>
The .name property does not resolve. Do I need to make changes on the Interface level for this to work? At the moment, my Interface looks quite simple:
export interface SomeResponse {
release_date: string;
genre_relation: string;
}
Thank you in advance for your help.