How I get value from JSON React Native?

Viewed 57

This is my JSON response. Can you please tell me how can I get daily array values? When I print console.log(data.timezone), It is working but how can I print daily[0].temp[0].day

{
  "lat": 7.3127,
  "lon": 80.6831,
  "timezone": "Asia/Colombo",
  "daily": [
    {
      "dt": 1639290600,
      "sunrise": 1639269596,
      "temp": {
        "day": 28.45,
        "min": 19.96,
        "max": 28.6,
      }
    },
    {
      "dt": 1639290600,
      "sunrise": 1639269596,
      "temp": {
        "day": 28.45,
        "min": 19.96,
        "max": 28.6,
      }
    }
    {
      "dt": 1639290600,
      "sunrise": 1639269596,
      "temp": {
        "day": 28.45,
        "min": 19.96,
        "max": 28.6,
      }
    }
    
  ]
}
2 Answers
daily = data.daily
for(let i=0; i < daily.length; i++){
console.log(daily[i].temp.day)
}

temp is not array ! is Object so you cant get index

console.log(data.daily[0].temp.day)
Related