Weather API data question

Weather API data question
0

#1

Hey guys and gals,

I don’t need any help getting my weather api project to work. I just started to make headway, my project isn’t done yet but I had a question about something.

I’m using the FCC api here: https://fcc-weather-api.glitch.me/

My questions is, when I’m getting information from the api such as:

  $.getJSON(url, function(data) {
    $("#temp").html(data.weather[0].description);
  });

Why do I have to specify “weather[0]” instead of just weather?


#2

from example data response from the API

"weather":[
  { "id":701,
    "main":"Mist",
    "description":"mist",
    "icon":"https://cdn.glitch.com/6e8889e5-7a72-48f0-a061-863548450de5%2F50n.png?1499366021876"
  }
]

so weather seems to be an Array of Object… weather[0].description would be the value of description key from the first object of that weather array.


#3

Yes its an array in a JSON object.