I have following JSON struncture:
{
"daypart": [
{
"temperature": [
45,
27,
47
]
}
]
}
I am trying to display arrays above from JSON API . l want to display only first element form this array , but am getting the following error
Error: Uncaught (in promise): TypeError: Cannot read property '1' of undefined
Code :
this.http.get("xxxxxxxx")
.subscribe(data => {
let f = data["daypart"][0]
this.duhok = f
console.log("duhok" + this.duhok["temperature"][1])
})
Html :
{{duhok.temperature[1]}}°