Need help with my weather app

Hello everyone,

So I have been working on my weather app project for some days now and I tried to lookup + understand all the API/JSON/JSONP stuff. But whenever I type my code on codepen, even the data of the geolocation doesn’t to show up!! Nothing that I type on my JS part seems to work. Only HTML. I’m stuck and I don’t know wha’t wrong with it.

What frustrates me more is that when I copy and paste other codes of other fellow campers on my codepen; it doesn’t work. But it works alll fine in the original codepens of their owners. I’m really confused!!:sweat:

I would appreciate any help that will put me our of my frustration. Thank you!

Check the browser’s console (and research any errors you see there) and report back to me.

The console part is empty. When I type console.log(“string”) outside of all the code it works fine in the console, but when I write console.log(data) inside the function(data) code to show my location/weather data on the console part, nothing appears

Are you loading the page using http?

Yes. I’m using http on my code pen. Do I have to change it to https?

No, you should keep http, because if you load it over https and are using http URLs in your code, you’ll get a mixed content error.

It’s actually working for me (if I use http to load the page), but it didn’t work at first, because the URL you pasted here to your pen is using https.


Your code works for me if i remove the “s” from “https” leaving it just “http” from the link you provided in OP…

1 Like

Thank you so much! And to think that I’ve read a note in a code mentioning this http/https problem. I guess stupidity has no boundaries :sweat_smile:

1 Like

Thank you! I’ve just tried that too and it worked :smiley:

I’d recommend using an API that uses https because Codepen will start forcing https in all pens in June + https is more secure.

1 Like

Oh I didn’t kow about that. Thank you for the heads up :smile:
When I add “s” to my links in the code it doesn’t work again :sweat_smile: should I change the whole API source?

Which means to use another API, like: Darsky, APIXU.

1 Like

Thank you again :+1: