I’m really struggling on the Weather App challenge, particularly with getting my variables to show data on my HTML page. I just can’t “see” what I’ve done wrong there. Would someone mind helping out by taking a look?
http://codepen.io/mbabaian/full/MpjbZv/
I’m including a screenshot of the API data if that helps.
I appreciate any and all help with this.
condition
is a single object, not an array. So,
var currentWeather = wd.current.condition[0].text;
Should be
var currentWeather = wd.current.condition.text;
Also, use https://api.apixu.com
(notice the s
at the end of https
) instead of the insecure hosting. You won’t notice a difference, but your users probably will. This will allow you to use the browser’s geolocation if you’d like a more accurate weather reading, too.
Thanks for the tip on the currenWeather. I wasn’t sure whether to include the [0], so it’s good to know that wasn’t necessary.
BTW I was able to resolve the main issue. I didn’t have the script link at the end of the page, so it never got the chance to load. It seems to be working fine now.
Thanks again!