When trying to access a property from the object, I encountered an error. The JSON format received from the server is as follows:
{
"result": false,
"messages": "welcome",
"data": [
{
"name": "siva",
"category": true,
"count": 3
}
]
}
Below is my code snippet attempting to retrieve a property from the object:
this.dataService.getdata()
.subscribe(data => this.result = data['data'],
error => this.errorMsg = error
);
I am seeking guidance on what mistake I may have made in fetching the 'data' property from the JSON.
Initially, I tried using data.data
, but after switching to data['data']
, I encountered the following error: https://i.sstatic.net/DRc93.png