API, What did I do wrong?

I do not understand what I’m doing wrong. Can someone point it out

Thanks in advance,

Javarri

Hi there, have you checked the console for any error messages? Those will usually give you a good starting point.

I really wish FCC added more information on this. I cannot tell you how long I struggled with this, and how many others have. The issue is really simple. You can’t use OpenWeatherMap and navigator.geolocation at the same time More Info.

Simply put, geolocation on chrome requires https. OpenWeatherMap free does not support https and only works on http. For codepen, it is normally http, but you can load the page with https if you type it in yourself. I suggest using a different way to get user’s location as you are using http with codepen and openweathermap. I used ip-api.com, but you can use whatever.

Your other option is to move your site to a host with secured connection such as GitHub pages. You could then use navigator.geolocation, but you would then have to find a different api other than openweathermap. I would recommend this, because you will eventually want to move your sites off codepen, but they other solution above would be easier.

3 Likes

Thank you so much for that information. I decided to go with the first choice, but I am still having problems with my code.
What did I do wrong?

Thanks in advance

I must also add that a lot of people (me as well) used a proxy like crossorigin.me to ‘transform’ http api openweather link into https. This is a lazy solution but it works.