Weather app - help, please!

Weather app - help, please!
0

#1

By the way - I want to do this PURE JAVASCRIPT.

Hey there! To be clear, I’ve been sitting on this topic for a 3-5 days now… And I DO know how to get my location by a city name or coordinates etc… AND pass that into the HTML.
I’ve got a HUGE problem with JSON stuff. Thing is - I am trying to use data from “http://openweathermap.org/api”. I.m having some trouble with the IDEA - how to use the callback? I have no idea how to write my question correctly. Thing is, I just don’t know how to make use of the data. The closest thing that I have found is using this:

var url = "api.openweathermap.org/data/2.5/forecast/city?id=524901&APPID=1111111111";
function load(){
    loadJSON(url, gotData)
}
function gotData(data){
    console.log(data)
}

but it seems I am doing something HORRIBLY wrong here, because not a single time I’ve got SOME KIND of response from THIS code or 100000+ variations of it. And oddly enough - it seems I can’t get any info on loadJSON thingy… So i am going blind in here.
Thank you very much, ANY HELP is appreciated, because it seems nobody in the chat seem to notice me :frowning: no help for 3 days… that’s rough.


#2

I assume APPID=1111111111 is replaced by a valid APPID?

if so, what happens if you paste just the query string into a browser, do you get back a JSON object?

It should return something like this:

http://api.openweathermap.org/data/2.5/weather?lat=44.4&lon=64.4&APPID=936

{“coord”:{“lon”:64.67,“lat”:45.08},“weather”:[{“id”:804,“main”:“Clouds”,“description”:“overcast clouds”,“icon”:“04n”}],“base”:“cmc stations”,“main”:{“temp”:297.605,“pressure”:1011.01,“humidity”:30,“temp_min”:297.605,“temp_max”:297.605,“sea_level”:1025.02,“grnd_level”:1011.01},“wind”:{“speed”:3.21,“deg”:40.5012},“clouds”:{“all”:92},“dt”:1465922181,“sys”:{“message”:0.0023,“country”:“KZ”,“sunrise”:1465862019,“sunset”:1465918206},“id”:1524478,“name”:“Dzhalagash”,“cod”:200}


#3

Well yeah, it SHOULD… but it doesn’t seem to return ANYTHING… Watched the tutorials online, and it seems that I know A LOT about the JSON by now, but still - can’t get THIS:

{"coord":{"lon":64.67,"lat":45.08},"weather":[{"id":804,"main":"Clouds","description":"overcast
 clouds","icon":"04n"}],"base":"cmc 
stations","main":{"temp":297.605,"pressure":1011.01,"humidity":30,"temp_min":297.605,"temp_max":297.605,"sea_level":1025.02,"grnd_level":1011.01},"wind":{"speed":3.21,"deg":40.5012},"clouds":{"all":92},"dt":1465922181,"sys":{"message":0.0023,"country":"KZ","sunrise":1465862019,"sunset":1465918206},"id":1524478,"name":"Dzhalagash","cod":200}

#4

Again, just to be clear, the APPID is 32 alpha-numeric characters long.

I see you clicked on my link above- the link will not work because I removed most of my APPID because its private data.

You have to sign up to openweathermap and then your account will have its own private APPID key that you will use.

Now you may already have done this, but from your reply it isn’t clear that you have an account set up and your own key. Nothing is going to work for you without it…


#5

I’ve got the acc and ID and have even assigned that the callback return in Celsius… I’ve done all that. The problem is with the javascript function - it doesn’t return anything. That’s why I need help.


#7

Fair enough. But until you can paste your query string into a browser and have it return a JSON object your JavaScript/JQuery code is never going to work.

Troubleshoot that query string - it has to be working first.

I just typed in the query string you posted above using my APPID and it is working, I got back a BIG JSON object.

That’s why I think your APPID may be the issue…


#8

YOUR query string returned this:

{
  "city": {
    "id": 524901,
    "name": "Moscow",
    "coord": {
      "lon": 37.615555,
      "lat": 55.75222
    },
    "country": "RU",
    "population": 0,
    "sys": {
      "population": 0
    }
  },
  "cod": "200",
  "message": 0.0281,
  "cnt": 40,
  "list": [
    {
      "dt": 1465927200,
      "main": {
        "temp": 289.15,
        "temp_min": 289.15,
        "temp_max": 289.305,
        "pressure": 1005.42,
        "sea_level": 1024.9,
        "grnd_level": 1005.42,
        "humidity": 64,
        "temp_kf": -0.16
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 8
      },
      "wind": {
        "speed": 1.61,
        "deg": 96.5012
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-14 18:00:00"
    },
    {
      "dt": 1465938000,
      "main": {
        "temp": 284.8,
        "temp_min": 284.8,
        "temp_max": 284.92,
        "pressure": 1005.79,
        "sea_level": 1025.31,
        "grnd_level": 1005.79,
        "humidity": 79,
        "temp_kf": -0.12
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "02n"
        }
      ],
      "clouds": {
        "all": 8
      },
      "wind": {
        "speed": 2.42,
        "deg": 140
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-14 21:00:00"
    },
    {
      "dt": 1465948800,
      "main": {
        "temp": 282.6,
        "temp_min": 282.6,
        "temp_max": 282.678,
        "pressure": 1005.71,
        "sea_level": 1025.31,
        "grnd_level": 1005.71,
        "humidity": 87,
        "temp_kf": -0.08
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02n"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 1.42,
        "deg": 82.5064
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-15 00:00:00"
    },
    {
      "dt": 1465959600,
      "main": {
        "temp": 286.53,
        "temp_min": 286.53,
        "temp_max": 286.567,
        "pressure": 1005.97,
        "sea_level": 1025.5,
        "grnd_level": 1005.97,
        "humidity": 85,
        "temp_kf": -0.04
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": {
        "all": 48
      },
      "wind": {
        "speed": 3.01,
        "deg": 95.0027
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-15 03:00:00"
    },
    {
      "dt": 1465970400,
      "main": {
        "temp": 291.343,
        "temp_min": 291.343,
        "temp_max": 291.343,
        "pressure": 1006.09,
        "sea_level": 1025.42,
        "grnd_level": 1006.09,
        "humidity": 76,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 56
      },
      "wind": {
        "speed": 3.56,
        "deg": 102.502
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-15 06:00:00"
    },
    {
      "dt": 1465981200,
      "main": {
        "temp": 294.373,
        "temp_min": 294.373,
        "temp_max": 294.373,
        "pressure": 1005.41,
        "sea_level": 1024.6,
        "grnd_level": 1005.41,
        "humidity": 72,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 12
      },
      "wind": {
        "speed": 4.46,
        "deg": 110.001
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-15 09:00:00"
    },
    {
      "dt": 1465992000,
      "main": {
        "temp": 296.283,
        "temp_min": 296.283,
        "temp_max": 296.283,
        "pressure": 1004.55,
        "sea_level": 1023.76,
        "grnd_level": 1004.55,
        "humidity": 65,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 12
      },
      "wind": {
        "speed": 4.38,
        "deg": 115.003
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-15 12:00:00"
    },
    {
      "dt": 1466002800,
      "main": {
        "temp": 296.123,
        "temp_min": 296.123,
        "temp_max": 296.123,
        "pressure": 1003.43,
        "sea_level": 1022.69,
        "grnd_level": 1003.43,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 80
      },
      "wind": {
        "speed": 3.86,
        "deg": 121.001
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-15 15:00:00"
    },
    {
      "dt": 1466013600,
      "main": {
        "temp": 294.664,
        "temp_min": 294.664,
        "temp_max": 294.664,
        "pressure": 1003.08,
        "sea_level": 1022.42,
        "grnd_level": 1003.08,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": {
        "all": 48
      },
      "wind": {
        "speed": 3.65,
        "deg": 108.003
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-15 18:00:00"
    },
    {
      "dt": 1466024400,
      "main": {
        "temp": 293.141,
        "temp_min": 293.141,
        "temp_max": 293.141,
        "pressure": 1002.61,
        "sea_level": 1022.03,
        "grnd_level": 1002.61,
        "humidity": 70,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10n"
        }
      ],
      "clouds": {
        "all": 56
      },
      "wind": {
        "speed": 4.46,
        "deg": 99.5006
      },
      "rain": {
        "3h": 0.555
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-15 21:00:00"
    },
    {
      "dt": 1466035200,
      "main": {
        "temp": 292.63,
        "temp_min": 292.63,
        "temp_max": 292.63,
        "pressure": 1002.57,
        "sea_level": 1021.87,
        "grnd_level": 1002.57,
        "humidity": 74,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03n"
        }
      ],
      "clouds": {
        "all": 36
      },
      "wind": {
        "speed": 4.56,
        "deg": 108.504
      },
      "rain": {},
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-16 00:00:00"
    },
    {
      "dt": 1466046000,
      "main": {
        "temp": 292.816,
        "temp_min": 292.816,
        "temp_max": 292.816,
        "pressure": 1002.79,
        "sea_level": 1022.06,
        "grnd_level": 1002.79,
        "humidity": 76,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 3.26,
        "deg": 120.504
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-16 03:00:00"
    },
    {
      "dt": 1466056800,
      "main": {
        "temp": 295.503,
        "temp_min": 295.503,
        "temp_max": 295.503,
        "pressure": 1002.12,
        "sea_level": 1021.38,
        "grnd_level": 1002.12,
        "humidity": 73,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": {
        "all": 48
      },
      "wind": {
        "speed": 3.96,
        "deg": 109.506
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-16 06:00:00"
    },
    {
      "dt": 1466067600,
      "main": {
        "temp": 296.959,
        "temp_min": 296.959,
        "temp_max": 296.959,
        "pressure": 1002.22,
        "sea_level": 1021.47,
        "grnd_level": 1002.22,
        "humidity": 67,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 64
      },
      "wind": {
        "speed": 6.17,
        "deg": 159.505
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-16 09:00:00"
    },
    {
      "dt": 1466078400,
      "main": {
        "temp": 296.911,
        "temp_min": 296.911,
        "temp_max": 296.911,
        "pressure": 1002.42,
        "sea_level": 1021.46,
        "grnd_level": 1002.42,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 80
      },
      "wind": {
        "speed": 7.02,
        "deg": 156.001
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-16 12:00:00"
    },
    {
      "dt": 1466089200,
      "main": {
        "temp": 296.925,
        "temp_min": 296.925,
        "temp_max": 296.925,
        "pressure": 1001.12,
        "sea_level": 1020.36,
        "grnd_level": 1001.12,
        "humidity": 59,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 56
      },
      "wind": {
        "speed": 4.71,
        "deg": 165.502
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-16 15:00:00"
    },
    {
      "dt": 1466100000,
      "main": {
        "temp": 295.549,
        "temp_min": 295.549,
        "temp_max": 295.549,
        "pressure": 1001.7,
        "sea_level": 1020.9,
        "grnd_level": 1001.7,
        "humidity": 63,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 76
      },
      "wind": {
        "speed": 3.86,
        "deg": 171.502
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-16 18:00:00"
    },
    {
      "dt": 1466110800,
      "main": {
        "temp": 293.493,
        "temp_min": 293.493,
        "temp_max": 293.493,
        "pressure": 1002.01,
        "sea_level": 1021.26,
        "grnd_level": 1002.01,
        "humidity": 77,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10n"
        }
      ],
      "clouds": {
        "all": 76
      },
      "wind": {
        "speed": 2.86,
        "deg": 199.003
      },
      "rain": {
        "3h": 0.53
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-16 21:00:00"
    },
    {
      "dt": 1466121600,
      "main": {
        "temp": 290.327,
        "temp_min": 290.327,
        "temp_max": 290.327,
        "pressure": 1002.42,
        "sea_level": 1021.7,
        "grnd_level": 1002.42,
        "humidity": 95,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 501,
          "main": "Rain",
          "description": "moderate rain",
          "icon": "10n"
        }
      ],
      "clouds": {
        "all": 92
      },
      "wind": {
        "speed": 2.42,
        "deg": 226.507
      },
      "rain": {
        "3h": 4.635
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-17 00:00:00"
    },
    {
      "dt": 1466132400,
      "main": {
        "temp": 289.883,
        "temp_min": 289.883,
        "temp_max": 289.883,
        "pressure": 1003.19,
        "sea_level": 1022.6,
        "grnd_level": 1003.19,
        "humidity": 99,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 501,
          "main": "Rain",
          "description": "moderate rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 92
      },
      "wind": {
        "speed": 2.56,
        "deg": 221.506
      },
      "rain": {
        "3h": 11.005
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-17 03:00:00"
    },
    {
      "dt": 1466143200,
      "main": {
        "temp": 293.556,
        "temp_min": 293.556,
        "temp_max": 293.556,
        "pressure": 1004.59,
        "sea_level": 1023.94,
        "grnd_level": 1004.59,
        "humidity": 97,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 44
      },
      "wind": {
        "speed": 3.66,
        "deg": 242.508
      },
      "rain": {
        "3h": 0.74
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-17 06:00:00"
    },
    {
      "dt": 1466154000,
      "main": {
        "temp": 295.246,
        "temp_min": 295.246,
        "temp_max": 295.246,
        "pressure": 1006.11,
        "sea_level": 1025.27,
        "grnd_level": 1006.11,
        "humidity": 93,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 12
      },
      "wind": {
        "speed": 4.11,
        "deg": 244.003
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-17 09:00:00"
    },
    {
      "dt": 1466164800,
      "main": {
        "temp": 295.937,
        "temp_min": 295.937,
        "temp_max": 295.937,
        "pressure": 1007.48,
        "sea_level": 1026.78,
        "grnd_level": 1007.48,
        "humidity": 84,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 4.68,
        "deg": 263
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-17 12:00:00"
    },
    {
      "dt": 1466175600,
      "main": {
        "temp": 295.658,
        "temp_min": 295.658,
        "temp_max": 295.658,
        "pressure": 1008.09,
        "sea_level": 1027.38,
        "grnd_level": 1008.09,
        "humidity": 80,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 12
      },
      "wind": {
        "speed": 2.92,
        "deg": 267.503
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-17 15:00:00"
    },
    {
      "dt": 1466186400,
      "main": {
        "temp": 292.197,
        "temp_min": 292.197,
        "temp_max": 292.197,
        "pressure": 1008.64,
        "sea_level": 1028.06,
        "grnd_level": 1008.64,
        "humidity": 85,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.42,
        "deg": 214.5
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-17 18:00:00"
    },
    {
      "dt": 1466197200,
      "main": {
        "temp": 288.625,
        "temp_min": 288.625,
        "temp_max": 288.625,
        "pressure": 1008.9,
        "sea_level": 1028.35,
        "grnd_level": 1008.9,
        "humidity": 87,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.76,
        "deg": 194.502
      },
      "rain": {},
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-17 21:00:00"
    },
    {
      "dt": 1466208000,
      "main": {
        "temp": 288.328,
        "temp_min": 288.328,
        "temp_max": 288.328,
        "pressure": 1008.69,
        "sea_level": 1028.2,
        "grnd_level": 1008.69,
        "humidity": 82,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03n"
        }
      ],
      "clouds": {
        "all": 48
      },
      "wind": {
        "speed": 2.85,
        "deg": 156.001
      },
      "rain": {},
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-18 00:00:00"
    },
    {
      "dt": 1466218800,
      "main": {
        "temp": 290.769,
        "temp_min": 290.769,
        "temp_max": 290.769,
        "pressure": 1007.4,
        "sea_level": 1026.77,
        "grnd_level": 1007.4,
        "humidity": 87,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 92
      },
      "wind": {
        "speed": 3.76,
        "deg": 166.5
      },
      "rain": {
        "3h": 0.005
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-18 03:00:00"
    },
    {
      "dt": 1466229600,
      "main": {
        "temp": 294.135,
        "temp_min": 294.135,
        "temp_max": 294.135,
        "pressure": 1006.28,
        "sea_level": 1025.54,
        "grnd_level": 1006.28,
        "humidity": 84,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 80
      },
      "wind": {
        "speed": 5.12,
        "deg": 188.501
      },
      "rain": {
        "3h": 0.01
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-18 06:00:00"
    },
    {
      "dt": 1466240400,
      "main": {
        "temp": 294.285,
        "temp_min": 294.285,
        "temp_max": 294.285,
        "pressure": 1005.31,
        "sea_level": 1024.58,
        "grnd_level": 1005.31,
        "humidity": 88,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 92
      },
      "wind": {
        "speed": 6.01,
        "deg": 194.007
      },
      "rain": {
        "3h": 0.86
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-18 09:00:00"
    },
    {
      "dt": 1466251200,
      "main": {
        "temp": 296.157,
        "temp_min": 296.157,
        "temp_max": 296.157,
        "pressure": 1005.64,
        "sea_level": 1024.92,
        "grnd_level": 1005.64,
        "humidity": 93,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 44
      },
      "wind": {
        "speed": 4.83,
        "deg": 236.508
      },
      "rain": {
        "3h": 1.55
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-18 12:00:00"
    },
    {
      "dt": 1466262000,
      "main": {
        "temp": 295.412,
        "temp_min": 295.412,
        "temp_max": 295.412,
        "pressure": 1007.03,
        "sea_level": 1026.22,
        "grnd_level": 1007.03,
        "humidity": 71,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 5.78,
        "deg": 258.005
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-18 15:00:00"
    },
    {
      "dt": 1466272800,
      "main": {
        "temp": 292.545,
        "temp_min": 292.545,
        "temp_max": 292.545,
        "pressure": 1008.55,
        "sea_level": 1027.99,
        "grnd_level": 1008.55,
        "humidity": 66,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 4.46,
        "deg": 260.001
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-18 18:00:00"
    },
    {
      "dt": 1466283600,
      "main": {
        "temp": 290.475,
        "temp_min": 290.475,
        "temp_max": 290.475,
        "pressure": 1009.63,
        "sea_level": 1029.08,
        "grnd_level": 1009.63,
        "humidity": 69,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 3.76,
        "deg": 249.502
      },
      "rain": {},
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-18 21:00:00"
    },
    {
      "dt": 1466294400,
      "main": {
        "temp": 289.048,
        "temp_min": 289.048,
        "temp_max": 289.048,
        "pressure": 1010.22,
        "sea_level": 1029.76,
        "grnd_level": 1010.22,
        "humidity": 73,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 3.41,
        "deg": 233.01
      },
      "rain": {},
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2016-06-19 00:00:00"
    },
    {
      "dt": 1466305200,
      "main": {
        "temp": 290.034,
        "temp_min": 290.034,
        "temp_max": 290.034,
        "pressure": 1010.82,
        "sea_level": 1030.31,
        "grnd_level": 1010.82,
        "humidity": 72,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 3.71,
        "deg": 227.503
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-19 03:00:00"
    },
    {
      "dt": 1466316000,
      "main": {
        "temp": 294.437,
        "temp_min": 294.437,
        "temp_max": 294.437,
        "pressure": 1010.59,
        "sea_level": 1030.06,
        "grnd_level": 1010.59,
        "humidity": 71,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 4.01,
        "deg": 229.504
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-19 06:00:00"
    },
    {
      "dt": 1466326800,
      "main": {
        "temp": 296.056,
        "temp_min": 296.056,
        "temp_max": 296.056,
        "pressure": 1010.24,
        "sea_level": 1029.51,
        "grnd_level": 1010.24,
        "humidity": 64,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 5.56,
        "deg": 240
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-19 09:00:00"
    },
    {
      "dt": 1466337600,
      "main": {
        "temp": 296.99,
        "temp_min": 296.99,
        "temp_max": 296.99,
        "pressure": 1009.95,
        "sea_level": 1029.22,
        "grnd_level": 1009.95,
        "humidity": 58,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 6.01,
        "deg": 246.5
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-19 12:00:00"
    },
    {
      "dt": 1466348400,
      "main": {
        "temp": 296.857,
        "temp_min": 296.857,
        "temp_max": 296.857,
        "pressure": 1009.63,
        "sea_level": 1028.94,
        "grnd_level": 1009.63,
        "humidity": 51,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 5.68,
        "deg": 258.505
      },
      "rain": {},
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2016-06-19 15:00:00"
    }
  ]
}

#9

The URL meybe DOES give you callback. but i have NO IDEA how to write that in a code <-- that’s the problem you see :slight_smile:


#10

I’m sorry @criativ but you’re missing my point. YOU need to be able to do this in a browser and have it work. FORGET THE CODE! Forget about the code until you get that query string working. You need to be able to reproduce my result above in your browser - no code involved. If you cannot do this first, the code you are trying to make work NEVER will.

You should be able to cut-and-paste the string you provided in your first post, add a valid APPID to the end of it, hit the enter key and have your browser display the JSON I pasted above. If you cannot get this to work then you APPID is not valid.


#11

Friend - I hope that didn’t come across as harsh, I apologize if it did. But what you posted at the very start works - it works provided you supply a valid appid.

You are very close to having it work I think…


#12


#13
var url = "http://api.openweathermap.org/data/2.5/weather?q=Ma%C5%BEeikiai&APPID=f68fa51a47989cd5522fd86f9a9003e3&units=metric";

function load(){
    loadJSON(url, gotData);
}
function gotData(data){
        console.log(data);
}

Here is the JS side, the URL returns EXACTLY my city if you click on the link. So now, the problem is that AGAIN - how do I access the data? Because my code returns NOTHING to me… I tried it in different browsers…


#14

Your getting the function loadJSON() from p5.js ?

http://p5js.org/reference/#/p5/loadJSON

You’ve included the library?


#15

Library? Isn’t the JSON included in the javascript???


#16

I think I’ll just find another way to do that.
Thank you for your time.


#17

getJSON() is a JavaScript function but loadJSON() appears to be part of the p5.js library.

Have a quick look here:

http://p5js.org/reference/#/p5/loadJSON


#18

If you want to do this in vanilla JavaScript, you need to learn how to use XMLHttpRequest to get the data. Look that up and it will solve your problem.


#19

Thank you very much! :slight_smile: I will do that.
P.S. Even if I lost a couple of days, I gained some knowledge… and I value it A LOT :slight_smile:


#20

For sure. There’s no such thing as wasted time just because you can’t get something to work. While you stumble around looking for the solution, you’re learning a LOT of stuff along the way that you’ll be able to use in the future.


#21

If SOMEONE else is having some problems with this ASSIGNMENT - “Make a Weather APP”. I would recommend:

  1. Invest your time in understanding JSON structured files, how to get what you need from one.
  2. Understand how to use XMLHttpRequest(P.S. THIS VIDEO was VERY helpfull!) --> https://www.youtube.com/watch?v=uXbL85IkwJ0
  3. Patience :slight_smile: Good luck!