JSON call function won't execute any code within it - "Show the local weather" challenge

JSON call function won't execute any code within it - "Show the local weather" challenge
0.0 0

#1

Hi guys, I’m truly stumped with this one.

While doing the Local Weather App challenge, I made a JSON call to Dark Sky API - I know that this API call is working because pasting the API link into my browser takes me to the JSON and running the Codepen app increases my API call count on Dark Sky’s API usage monitor.

The problem is that the function embedded in the getJSON won’t run any of the code that I place within it. As you will see from my code, I can’t even get it to append a simple Hello World to the HTML or even get it to return a string to the console.

Hopefully I’m not being dumb and forgetting a bracket somewhere but as far as I can tell, all the syntax is correct and Codepen agrees with me.

Here is my Codepen: https://codepen.io/ottyk/pen/NgXpGg?editors=1111

Thanks in advance for taking the time to look through my code. :grin:


#2

Its because the API blocks cross origin requests. Append &callback=? to end of DarkSkyURL. That should convert it to a JSONP call and then all will be well and it won’t get blocked.


#3

That worked, thanks! The API I used for the last challenge added that in automatically so I totally forgot about it.