I want to display data using beego and golang. But I have a problem because I get is nested json data and I can't find a way to solve it, can you help me cause i'm new in beego and golang.
here's the nested json i got
[{
"AppId":1233,
"AppStatus":"approved",
"AppStatusVerification":"retur",
"AppFullname":"Dadang Subur",
"UpdatedAt":"2022-03-31T11:54:07.283Z",
"CreatedAt":"2021-03-23T06:20:07.877Z",
"History":[
{
"Id":1233,
"Name":"approved",
"Time":"2022-03-28T17:31:24.55Z",
"ActorId":1232,
"ActorName":""
},
{
"Id":1233,
"Name":"approved",
"Time":"2022-03-28T16:33:29.033Z",
"ActorId":1232,
"ActorName":""
}}]
And code .tpl i used
<tbody>
{{range $record := .records}}
<tr>
<td>{{$record.AppId}}</td>
<td>{{$record.AppFullname}}</td>
<td>{{$record.AppStatus}}</td>
<td>{{$record.CreatedAt}}</td>
<td>{{$record.UpdatedAt}}</td>
</tr>
{{end}}
</tbody>
Cause when i used <td>{{$record.Name}}</td> to get "approved", the result is executing "eform/listAllActivityHistoryAgent.tpl" at <$record.Name>: can't evaluate field Name in type models.HistoryData
Thank you in advance
History is also an array so you need to iterate in the tpl.
Please try this;