I built the local weather app on Codepen. I decided to move it over to Github to try out pages, but for some reason the weather information never loads. It just asks if I want to share my location. All of the other JS seems to be working fine, so I’m stumped. If anyone could help, I would appreciate it! Thanks!
Looks like in your script.js file, line 276/277 you’re closing the script on the following line.
> var api = ‘http://api.openweathermap.org/data/2.5/weather?lat=’ + lat + ‘&lon=’ + lon + '&units=imperial&APPID=ec50a6072ac189dee111acdd3a38ab9f
';
and that actually throws an error in the console.
I am assuming and this is the issue… I just don’t know how to fix it.
EDIT
I just tested in FireFox, and the same thing happened. It seems that the browser is blocking the request to share location. I clicked “disable protection”, and everything appeared. Does anyone know how to fix this?
Looks like since the Github page is served over HTTPS the openweather api should also be invoked over HTTPS. Try adding a condition based on the location.protocol and if the page is HTTPS then you want to call the https version of the api, something like:
@nikkilr88 I have the same issue when I try to push React apps which use API calls on GitHub pages. I don’t understand the link you provided. Can you explain or give more researches to learn from.
Thanks