0

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 2

1
daily = data.daily
for(let i=0; i < daily.length; i++){
console.log(daily[i].temp.day)
}
Sign up to request clarification or add additional context in comments.

Comments

0

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

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.