Having trouble calling OpenWeatherMap to my Local Weather Machine

Having trouble calling OpenWeatherMap to my Local Weather Machine
0

#1

Hello,

I’ve been trying to get started on the Show the Local Weather challenge and have got completely stuck.

The worst problem is that my current code originally worked! However when I came back to it the next day to carry on working on it, it didn’t work and I haven’t been able to get it to work since.

Does anyone mind having a look and maybe see what I’m doing wrong? I know I have to use the user’s current location but I just put in my own location at first to try and get it working before worrying about that.

Cheers,
Stuart


#2

Huh. Some places are just more fun to work at than others.

TypeError: undefined is not an object (evaluating 'e.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED')

The heart of this issue is browser security. You’re connected to CodePen via HTTPS, which is good, but you’re trying to access remote resources that are not securely hosted (via HTTP), which is not good. The simplest solution at this point is to tack https://crossorigin.me in front of your apiURL.

var apiURL = 
"https://crossorigin.me/http://api.openweathermap.org/data/2.5/weather?q=Plymouth,uk&APPID=339aeea1f4e7888fdcac76a9fa4ba74c&units=metric";`

#3

Codepen.io is using HTTPS protocol, while the site you’re making ajax requests to, OpenWeather, is using HTTP protocol. For more information, see this link. If you export your code as zip & run it on your local machine, I hope it’ll work.


#4

Thanks for the replies guys.

I added the crossorigin address to the beginning of my apiURL variable - and it worked perfectly!

I had no idea about the HTTP/HTTPS protocol stuff, so that mixed content link was a big help and I understand it a lot more now.

Thanks again for the help! I can finally move on with this project. :grinning:


#5

Hello Guys,

I have been doing the weather app challenge also. The Open Weather Api has some issues as its free version uses http and codepen uses https so mixed content warning is displayed.

I used this API here in my project, its free and uses https, so no warnings are there and the app works perfectly.

Also my weather app that i completed today only is here

Hope this helps.

Regards,
Kush


#6

Very nice. A service that is hosted securely is the best solution :thumbsup:


#7

Thanks for posting that Kush, I had further problems with Open Weather Map so decided to give the Axipu one a try and seems to be working great so far. It is working with the geolocation function too which is a bonus. And all with HTTPS!


#8

You are welcome bro. Yeah this service seems to be secure and free, and returns loads of data which can be used in our weather apps.:slight_smile: