this.http.post(this.url + "/DeptWiseCount", {
startDate: this.newStartDate,
endDate: this.newEndDate
}).subscribe(
data => (
this.response = JSON.stringify(data),
console.log(this.response + data[0]["port_count"])
),
error => (
this.handleError(error)
)
)
In the above code I am simply want to get data from the API in my console log but it throw an error i.e. Cannot read properties of undefined (reading 'port_count')
. I don't know why? Please help me. API output as mention below:
{
"data": [
{
"key": "Pending",
"total_count": 576871,
"traffic": 2,
"traf_count": 502045,
"port": 1,
"port_count": 74826
},
{
"key": "Cash",
"total_count": 305414,
"traffic": 2,
"traf_count": 245316,
"port": 1,
"port_count": 60098
}
]
}
Thank You