Problems with APIs in codepen

Hey guys. I need help working with APIs in code pen. it doesnt seem to get the API call. it doesnt even work with the geolocation challenge

Do you have a link?

Also, most likely there will be an error message in your browser console with more information.

the error message says “Type error, $.getJson is not a function”


should be


if it’s any consolation, it worked on my end, but I’m running MSedge and had to disable just about every single security feature in my browser just to be able work in CodePen -.-

Fixed my problem. Thanks a lot

1 Like

is there anything wrong with this string concatenation?
var apiCall = ""+lat+"&lon="+long+"&appid=4c78e3460c3ae1baf6c9b67990be0803";

here’s how I broke the call down, note that I had to set the var OWM_API_KEY global (outside) and disable every security function in my MSedge browser for it to get me data.

$.getJSON('' + uLat + '&lon=' + uLon + '&appid=' + OWM_API_KEY + '&units=imperial'

the problem is that im actually getting data with hard coded longitude and latitude values. The minute i concatenate the variables, it stops working especially the longitude value.:sweat:

when I run it my side it looks like the weather api is running BEFORE the GeoIP lat/long is returned. So the weather API is running with this error:

> {“cod”:“502”,“message”:“Error: Not found city”}

notice the "undefined" lat/lon values …

I was starting to suspect that. What do you think i can do about it?

try this series from CodewithNick, it helped me a LOT:

Ill definitely do that. Thanks a lot

1 Like