Is there anything wrong with my JSON request? (Weather App)


#1

Can someone please tell me what is wrong with this? My console gives me this error and it’s the most aggravating feeling:

VM2499 jquery.min.js:4 GET https://s.codepen.io/boomerang/iFrameKey-6f19c899-296b-9492-c00c-a27a997426…ermap.org/data/2.5/weather?q=London&APPID=c4294c299d342c694f0c8cb6c524270b 404 ()

 var url = 'api.openweathermap.org/data/2.5/weather?q=London&APPID=c4294c299d342c694f0c8cb6c524270b';      
          
            console.log("url " + url);
          
            $.getJSON(url, function(data){
              console.log(data.weather);
            });

This is my codepen url: https://codepen.io/atalero/pen/XarREe

Thank you!


#2

Looks like your url is missing a protocol. http:// or https://

Without this, requests you make will be appended to the end of where your code is being run. You can see that your error message shows the codepen URL combined with your openweathermap url.


#3

Codepen requires you to use HTTPS:// for your API calls and Open Weather Map does not support HTTPS unless you pay for a premium plan. Replace your URL with the one recommended for the weather project:

https://fcc-weather-api.glitch.me/


#5

Yes, I realized everyone’s codepen was not working if they used the openweathermap. Thank you for your help! My project is finally making progress!