Problem with the weatherMap project

Problem with the weatherMap project
0

#1

i used the IP-API ’ http://ip-api.com/json ’ to get the lng and lat of my location using my ip address but it seems that it’s not working.


#2

#3

i used this

 $.getJSON('https://ip-api.com/json', function(json){
    lat = json.lat;
    lng = json.lon;
  });

but when I log the lat or the lng it’s appear that both are undefined


#4

Does ip-api.com support https?


#5

no it does not, but even with http nothing work.


#6

Is your codepen address http?


#7

yes it is that why i could not figure out what the problem. .


#8

Post the link to your codepen.


#9

#10

You are missing openweathermap API key


#11

before that I’m trying to get the latitude and longitude, so it didn’t work i mean before calling the weather map api
.


#12

Works for me. I get my coords in console.

  function getLatLon(){
    $.getJSON('http://ip-api.com/json', function(json){
      lat = json.lat;
      lng = json.lon;
      console.log(lat, lng) // <-- This shows my coords in console
    });
  } 

#13

So why it’s not working for me.


#14

i just try it in my brother’s computer and it worked perfectly, so what do you think the problem is?


#15

Are you getting a response in your browser if you just click the link directly?
http://ip-api.com/json


#16

yes when i do that i got a response.


#17

Post the screenshot of your Chrome console.


#18

well i was using fireFox now i switched to chrome and it worked thank for your time,
i was wondering why in fireFox didn’t work?


#19

Works in FF for me :sunglasses:


#20

thank you @jenovs for your help.