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.

0 Likes

#2
0 Likes

#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

0 Likes

#4

Does ip-api.com support https?

0 Likes

#5

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

0 Likes

#6

Is your codepen address http?

0 Likes

#7

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

0 Likes

#8

Post the link to your codepen.

0 Likes

#9
0 Likes

#10

You are missing openweathermap API key

0 Likes

#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
.

0 Likes

#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
    });
  } 
0 Likes

#13

So why it’s not working for me.

0 Likes

#14

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

0 Likes

#15

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

0 Likes

#16

yes when i do that i got a response.

0 Likes

#17

Post the screenshot of your Chrome console.

0 Likes

#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?

0 Likes

#19

Works in FF for me :sunglasses:

0 Likes

#20

thank you @jenovs for your help.

0 Likes