Cannot log open weather API in my page

I am working on the weather forecast project.
I am able to get the coordinate of my location but then I cannot use them to get the weather there.
If I try console.log, what I get is “jQuery.Deferred exception: loc is undefined” “@pen.js:27:6
” undefined

Here is the link to my pen, an help would be really much appreciated.

Hi, the weather challenge was updated recently. FCC created it’s own API that will hopefully solve your issue. You can access that new API at

Here is except from the updated challenge:

Note: Many internet browsers now require an HTTP Secure (https://) connection to obtain a user’s locale via HTML5 Geolocation. For this reason, we recommend using HTML5 Geolocation to get user location and then use the freeCodeCamp Weather API which uses an HTTP Secure connection for the weather. Also, be sure to connect to via https://.

Thanks @marigerr but the problem is not the api itself, since if I write directly an example (wothout variables) it does work.
I suggest that the problem is the way I wrote the function but cannot figure out myself

ah ok, I see now a problem. You need to wait to make your call to the weather API until after you have received the coordinates from One way to do this is to move it into the callback directly under line 12. If you still have problems, you might try using the new fcc weather api.

Ok you mean this?

var key = “c68c9b83e1b2903741314ae01c58f011”;

$(document).ready(function() {

var loc;

$.getJSON(“”, function(data) {

console.log(“get some interesting data…”);
loc = data.loc.split(" , ");

 $.getJSON(""+loc[0]+"&lon="+loc[1]+"&appid=c68c9b83e1b2903741314ae01c58f011", function(weatherData)





Really appreciate your help, thank a lot