API call didn't work

API call didn't work


Hello , my api call didn’t work. here is js

var C=false;
var apiData;
' https://cdn.pixabay.com/photo/2013/12/09/13/45/waterfall-225961_960_720.jpg',

function displayTemp(F,C){
return Math.round((F-32)*(5/9)) +'° C';
return Math.round(F) +'° F';



// console.log(location);

$.getJSON('http://api.openweathermap.org/data/2.5/weather?lat='+location.latitute+'&lon='+location.longitude+'&units=imperial&appid=d99414c365ff0845c676431520203ea0', function(data){



Can anyone help me please?

thanks in advance


I cleaned up your code.
You need to use triple backticks to post code to the forum.
See this post for details.



I found two problems. First, JQuery isn’t loaded (maybe you loaded it in your html.)

The other problem is that you mispelled “latitude” in your url (location.latitute). I discovered this by consoling the whole url string to the console so I could see what it was producing and saw that the string contained “…lat=undefined…”.


thankyou, this is my first post so i didn’t understand…


I have loaded jquery. Yes i have mispelled , (thank you for pointing it) but i corrected it and checked again but it is not working .
Here is my link of codepen


What is not working?

When I run your pen, I get the correct data object in my console.

I have to make sure we’re clear - you know to check the console, right? I ask because there are a lot of beginners here that aren’t clear on things like this. There are two consoles - one in your browser (cntrl-shift-j to reach mine in Chrome) and one in the codepen program, at the bottom of the screen.

If you’re not getting that data object in your console, then I’m not sure what the problem is.


I am not getting data object in my console.
i am checking in codepen console . It does not show anything.when i run there is nothing on console.
I have also check on chrome console. It gives the error

Mixed Content: The page at ‘https://codepen.io/avi-jkiapt/pen/jmEbVa?editors=0011’ was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint ‘http://api.openweathermap.org/data/2.5/weather?lat=26.4667&lon=80.35&units=imperial&appid=d99414c365ff0845c676431520203ea0’. This request has been blocked; the content must be served over HTTPS.

Can you tell what i do?


OK, I wish you’d included that error message in your original post.

There can be problems when you call an http (unsecured) resource from an https (secured) resource.

I believe the problem is that you are calling http://api.openweathermap.org from https://codepen.io. I think if you switch one of those, your problem will be solved.


okay, I got it. It working thank you so much from bottom of my heart. Thanks a lot…


hey, that’s what we do here. Pretty soon you’ll be helping someone with the same problem.