Local Weather, getting undefined when trying to get weather type data from the fcc api [CLOSED]

https://codepen.io/simongjetaj/pen/KXvrVM?editors=0011

Hey Guys,

I am working on my local weather app but I am getting undefined when trying to access the weather type from the fcc api. Seems that the api isn’t working correctly.
Could someone figure it out for me, please or should I use another api?

Thanks,
Simon

Hey. The weather property is an array:

so you’ll need to access it through its index, like:

let weatherType = data.weather[0].main;
let weather = data.weather[0].description;

Also as a tip, if you’re using Chrome (don’t know about the other browsers), you can just hover on the object properties in your console and a popup will show you how to access them:

1 Like

Oo thanks, I just saw it… :sweat_smile:

And thank you also for the tip… :+1: