Is the response from the weather api an itterable?

Using javascript to try and extract some of the data in the response from the weather api and don’t know how ?

N/m I forgot to parse to JSON… thanks!

1 Like

You should be able to iterate over the response if it is an array or object. I iterated over my data, it all depends on how you call the api. Console.log the response to see if it is an array or object. If it is an array, you can do so like this:

async function getData() {
  let response = await fetch(WEATHER_LINK)
  let data = await response.json()
  console.log(data)

When I console.log my data variable, I will get something like this:

// 20170913165145
// http://api.openweathermap.org/data/2.5/forecast?q=IowaCity&appid=null

{
  "cod": "200",
  "message": 0.0047,
  "cnt": 40,
  "list": [
    {
      "dt": 1505347200,
      "main": {
        "temp": 298.46,
        "temp_min": 297.495,
        "temp_max": 298.46,
        "pressure": 993.04,
        "sea_level": 1019.39,
        "grnd_level": 993.04,
        "humidity": 70,
        "temp_kf": 0.97
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.31,
        "deg": 35.5068
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-14 00:00:00"
    },
    {
      "dt": 1505358000,
      "main": {
        "temp": 291.61,
        "temp_min": 290.886,
        "temp_max": 291.61,
        "pressure": 994.18,
        "sea_level": 1020.77,
        "grnd_level": 994.18,
        "humidity": 81,
        "temp_kf": 0.72
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.86,
        "deg": 94.001
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-14 03:00:00"
    },
    {
      "dt": 1505368800,
      "main": {
        "temp": 289.43,
        "temp_min": 288.946,
        "temp_max": 289.43,
        "pressure": 994.62,
        "sea_level": 1021.34,
        "grnd_level": 994.62,
        "humidity": 82,
        "temp_kf": 0.48
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.77,
        "deg": 133.501
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-14 06:00:00"
    },
    {
      "dt": 1505379600,
      "main": {
        "temp": 288.01,
        "temp_min": 287.773,
        "temp_max": 288.01,
        "pressure": 995.24,
        "sea_level": 1021.89,
        "grnd_level": 995.24,
        "humidity": 83,
        "temp_kf": 0.24
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.24,
        "deg": 167.501
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-14 09:00:00"
    },
    {
      "dt": 1505390400,
      "main": {
        "temp": 287.469,
        "temp_min": 287.469,
        "temp_max": 287.469,
        "pressure": 995.88,
        "sea_level": 1022.8,
        "grnd_level": 995.88,
        "humidity": 81,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 1.23,
        "deg": 154.502
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-14 12:00:00"
    },
    {
      "dt": 1505401200,
      "main": {
        "temp": 298.089,
        "temp_min": 298.089,
        "temp_max": 298.089,
        "pressure": 996.88,
        "sea_level": 1023.35,
        "grnd_level": 996.88,
        "humidity": 66,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 2.1,
        "deg": 175.507
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-14 15:00:00"
    },
    {
      "dt": 1505412000,
      "main": {
        "temp": 302.376,
        "temp_min": 302.376,
        "temp_max": 302.376,
        "pressure": 997.01,
        "sea_level": 1023.28,
        "grnd_level": 997.01,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 2.66,
        "deg": 202.503
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-14 18:00:00"
    },
    {
      "dt": 1505422800,
      "main": {
        "temp": 304.025,
        "temp_min": 304.025,
        "temp_max": 304.025,
        "pressure": 996.26,
        "sea_level": 1022.41,
        "grnd_level": 996.26,
        "humidity": 54,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 2.88,
        "deg": 196
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-14 21:00:00"
    },
    {
      "dt": 1505433600,
      "main": {
        "temp": 300.863,
        "temp_min": 300.863,
        "temp_max": 300.863,
        "pressure": 996.23,
        "sea_level": 1022.65,
        "grnd_level": 996.23,
        "humidity": 54,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 2.6,
        "deg": 166.505
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-15 00:00:00"
    },
    {
      "dt": 1505444400,
      "main": {
        "temp": 296.484,
        "temp_min": 296.484,
        "temp_max": 296.484,
        "pressure": 997.6,
        "sea_level": 1024.14,
        "grnd_level": 997.6,
        "humidity": 57,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "clouds": {
        "all": 88
      },
      "wind": {
        "speed": 3.66,
        "deg": 168.501
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-15 03:00:00"
    },
    {
      "dt": 1505455200,
      "main": {
        "temp": 294.659,
        "temp_min": 294.659,
        "temp_max": 294.659,
        "pressure": 998.31,
        "sea_level": 1024.97,
        "grnd_level": 998.31,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04n"
        }
      ],
      "clouds": {
        "all": 68
      },
      "wind": {
        "speed": 3.3,
        "deg": 175.5
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-15 06:00:00"
    },
    {
      "dt": 1505466000,
      "main": {
        "temp": 293.878,
        "temp_min": 293.878,
        "temp_max": 293.878,
        "pressure": 998.64,
        "sea_level": 1025.35,
        "grnd_level": 998.64,
        "humidity": 61,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04n"
        }
      ],
      "clouds": {
        "all": 80
      },
      "wind": {
        "speed": 2.76,
        "deg": 183.005
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-15 09:00:00"
    },
    {
      "dt": 1505476800,
      "main": {
        "temp": 294.208,
        "temp_min": 294.208,
        "temp_max": 294.208,
        "pressure": 999.55,
        "sea_level": 1026.19,
        "grnd_level": 999.55,
        "humidity": 58,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 76
      },
      "wind": {
        "speed": 4.1,
        "deg": 175.508
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-15 12:00:00"
    },
    {
      "dt": 1505487600,
      "main": {
        "temp": 297.753,
        "temp_min": 297.753,
        "temp_max": 297.753,
        "pressure": 1000.32,
        "sea_level": 1026.91,
        "grnd_level": 1000.32,
        "humidity": 57,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": {
        "all": 32
      },
      "wind": {
        "speed": 4.27,
        "deg": 165.008
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-15 15:00:00"
    },
    {
      "dt": 1505498400,
      "main": {
        "temp": 302.464,
        "temp_min": 302.464,
        "temp_max": 302.464,
        "pressure": 999.69,
        "sea_level": 1026.06,
        "grnd_level": 999.69,
        "humidity": 51,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 12
      },
      "wind": {
        "speed": 5.51,
        "deg": 160.001
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-15 18:00:00"
    },
    {
      "dt": 1505509200,
      "main": {
        "temp": 303.939,
        "temp_min": 303.939,
        "temp_max": 303.939,
        "pressure": 998.36,
        "sea_level": 1024.59,
        "grnd_level": 998.36,
        "humidity": 44,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01d"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 5.85,
        "deg": 170.001
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-15 21:00:00"
    },
    {
      "dt": 1505520000,
      "main": {
        "temp": 301.183,
        "temp_min": 301.183,
        "temp_max": 301.183,
        "pressure": 997.93,
        "sea_level": 1024.27,
        "grnd_level": 997.93,
        "humidity": 41,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 6.03,
        "deg": 163.001
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-16 00:00:00"
    },
    {
      "dt": 1505530800,
      "main": {
        "temp": 298.169,
        "temp_min": 298.169,
        "temp_max": 298.169,
        "pressure": 999.11,
        "sea_level": 1025.63,
        "grnd_level": 999.11,
        "humidity": 46,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 6.46,
        "deg": 160.502
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-16 03:00:00"
    },
    {
      "dt": 1505541600,
      "main": {
        "temp": 296.594,
        "temp_min": 296.594,
        "temp_max": 296.594,
        "pressure": 999.46,
        "sea_level": 1026.07,
        "grnd_level": 999.46,
        "humidity": 55,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 6.12,
        "deg": 167.5
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-16 06:00:00"
    },
    {
      "dt": 1505552400,
      "main": {
        "temp": 295.741,
        "temp_min": 295.741,
        "temp_max": 295.741,
        "pressure": 999.56,
        "sea_level": 1026.14,
        "grnd_level": 999.56,
        "humidity": 58,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 6.16,
        "deg": 172.004
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-16 09:00:00"
    },
    {
      "dt": 1505563200,
      "main": {
        "temp": 295.151,
        "temp_min": 295.151,
        "temp_max": 295.151,
        "pressure": 1000.4,
        "sea_level": 1027.06,
        "grnd_level": 1000.4,
        "humidity": 63,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 5.68,
        "deg": 177.001
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-16 12:00:00"
    },
    {
      "dt": 1505574000,
      "main": {
        "temp": 299.2,
        "temp_min": 299.2,
        "temp_max": 299.2,
        "pressure": 1001.38,
        "sea_level": 1027.98,
        "grnd_level": 1001.38,
        "humidity": 59,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 56
      },
      "wind": {
        "speed": 6.02,
        "deg": 185.504
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-16 15:00:00"
    },
    {
      "dt": 1505584800,
      "main": {
        "temp": 301.051,
        "temp_min": 301.051,
        "temp_max": 301.051,
        "pressure": 1001.25,
        "sea_level": 1027.68,
        "grnd_level": 1001.25,
        "humidity": 55,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 68
      },
      "wind": {
        "speed": 5.56,
        "deg": 191.015
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-16 18:00:00"
    },
    {
      "dt": 1505595600,
      "main": {
        "temp": 304.143,
        "temp_min": 304.143,
        "temp_max": 304.143,
        "pressure": 999.68,
        "sea_level": 1026.05,
        "grnd_level": 999.68,
        "humidity": 50,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 801,
          "main": "Clouds",
          "description": "few clouds",
          "icon": "02d"
        }
      ],
      "clouds": {
        "all": 20
      },
      "wind": {
        "speed": 5.66,
        "deg": 189
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-16 21:00:00"
    },
    {
      "dt": 1505606400,
      "main": {
        "temp": 302.742,
        "temp_min": 302.742,
        "temp_max": 302.742,
        "pressure": 999.02,
        "sea_level": 1025.43,
        "grnd_level": 999.02,
        "humidity": 49,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03n"
        }
      ],
      "clouds": {
        "all": 36
      },
      "wind": {
        "speed": 5.21,
        "deg": 189.003
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-17 00:00:00"
    },
    {
      "dt": 1505617200,
      "main": {
        "temp": 299.833,
        "temp_min": 299.833,
        "temp_max": 299.833,
        "pressure": 1000.16,
        "sea_level": 1026.61,
        "grnd_level": 1000.16,
        "humidity": 57,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "clouds": {
        "all": 88
      },
      "wind": {
        "speed": 3.56,
        "deg": 214.501
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-17 03:00:00"
    },
    {
      "dt": 1505628000,
      "main": {
        "temp": 299.297,
        "temp_min": 299.297,
        "temp_max": 299.297,
        "pressure": 1000.92,
        "sea_level": 1027.6,
        "grnd_level": 1000.92,
        "humidity": 61,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "clouds": {
        "all": 92
      },
      "wind": {
        "speed": 3.97,
        "deg": 215.503
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-17 06:00:00"
    },
    {
      "dt": 1505638800,
      "main": {
        "temp": 297.832,
        "temp_min": 297.832,
        "temp_max": 297.832,
        "pressure": 1001.75,
        "sea_level": 1028.55,
        "grnd_level": 1001.75,
        "humidity": 65,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10n"
        }
      ],
      "clouds": {
        "all": 76
      },
      "wind": {
        "speed": 3.22,
        "deg": 256.5
      },
      "rain": {
        "3h": 0.11
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-17 09:00:00"
    },
    {
      "dt": 1505649600,
      "main": {
        "temp": 294.641,
        "temp_min": 294.641,
        "temp_max": 294.641,
        "pressure": 1003.69,
        "sea_level": 1030.58,
        "grnd_level": 1003.69,
        "humidity": 85,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 64
      },
      "wind": {
        "speed": 3.92,
        "deg": 340.001
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-17 12:00:00"
    },
    {
      "dt": 1505660400,
      "main": {
        "temp": 296.008,
        "temp_min": 296.008,
        "temp_max": 296.008,
        "pressure": 1005.9,
        "sea_level": 1032.66,
        "grnd_level": 1005.9,
        "humidity": 69,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 76
      },
      "wind": {
        "speed": 6.12,
        "deg": 10.0014
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-17 15:00:00"
    },
    {
      "dt": 1505671200,
      "main": {
        "temp": 297.311,
        "temp_min": 297.311,
        "temp_max": 297.311,
        "pressure": 1006.18,
        "sea_level": 1032.85,
        "grnd_level": 1006.18,
        "humidity": 61,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 92
      },
      "wind": {
        "speed": 5.62,
        "deg": 13.0011
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-17 18:00:00"
    },
    {
      "dt": 1505682000,
      "main": {
        "temp": 297.837,
        "temp_min": 297.837,
        "temp_max": 297.837,
        "pressure": 1005.67,
        "sea_level": 1032.35,
        "grnd_level": 1005.67,
        "humidity": 57,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 88
      },
      "wind": {
        "speed": 5.11,
        "deg": 10
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-17 21:00:00"
    },
    {
      "dt": 1505692800,
      "main": {
        "temp": 295.829,
        "temp_min": 295.829,
        "temp_max": 295.829,
        "pressure": 1005.7,
        "sea_level": 1032.45,
        "grnd_level": 1005.7,
        "humidity": 54,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 804,
          "main": "Clouds",
          "description": "overcast clouds",
          "icon": "04n"
        }
      ],
      "clouds": {
        "all": 88
      },
      "wind": {
        "speed": 4.71,
        "deg": 25.0019
      },
      "rain": {
        
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-18 00:00:00"
    },
    {
      "dt": 1505703600,
      "main": {
        "temp": 293.478,
        "temp_min": 293.478,
        "temp_max": 293.478,
        "pressure": 1006.08,
        "sea_level": 1032.97,
        "grnd_level": 1006.08,
        "humidity": 60,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10n"
        }
      ],
      "clouds": {
        "all": 56
      },
      "wind": {
        "speed": 4.25,
        "deg": 47.0018
      },
      "rain": {
        "3h": 0.33
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-18 03:00:00"
    },
    {
      "dt": 1505714400,
      "main": {
        "temp": 291.628,
        "temp_min": 291.628,
        "temp_max": 291.628,
        "pressure": 1005.5,
        "sea_level": 1032.54,
        "grnd_level": 1005.5,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 800,
          "main": "Clear",
          "description": "clear sky",
          "icon": "01n"
        }
      ],
      "clouds": {
        "all": 0
      },
      "wind": {
        "speed": 3.67,
        "deg": 59.5012
      },
      "rain": {
        
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-18 06:00:00"
    },
    {
      "dt": 1505725200,
      "main": {
        "temp": 289.947,
        "temp_min": 289.947,
        "temp_max": 289.947,
        "pressure": 1005.66,
        "sea_level": 1032.55,
        "grnd_level": 1005.66,
        "humidity": 68,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03n"
        }
      ],
      "clouds": {
        "all": 32
      },
      "wind": {
        "speed": 2.56,
        "deg": 62.0013
      },
      "rain": {
        
      },
      "sys": {
        "pod": "n"
      },
      "dt_txt": "2017-09-18 09:00:00"
    },
    {
      "dt": 1505736000,
      "main": {
        "temp": 290.356,
        "temp_min": 290.356,
        "temp_max": 290.356,
        "pressure": 1005.41,
        "sea_level": 1032.22,
        "grnd_level": 1005.41,
        "humidity": 68,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 803,
          "main": "Clouds",
          "description": "broken clouds",
          "icon": "04d"
        }
      ],
      "clouds": {
        "all": 56
      },
      "wind": {
        "speed": 2.16,
        "deg": 75.0158
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-18 12:00:00"
    },
    {
      "dt": 1505746800,
      "main": {
        "temp": 294.383,
        "temp_min": 294.383,
        "temp_max": 294.383,
        "pressure": 1004.64,
        "sea_level": 1031.27,
        "grnd_level": 1004.64,
        "humidity": 87,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 500,
          "main": "Rain",
          "description": "light rain",
          "icon": "10d"
        }
      ],
      "clouds": {
        "all": 76
      },
      "wind": {
        "speed": 2.52,
        "deg": 116.503
      },
      "rain": {
        "3h": 0.54
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-18 15:00:00"
    },
    {
      "dt": 1505757600,
      "main": {
        "temp": 298.509,
        "temp_min": 298.509,
        "temp_max": 298.509,
        "pressure": 1003.07,
        "sea_level": 1029.54,
        "grnd_level": 1003.07,
        "humidity": 75,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": {
        "all": 48
      },
      "wind": {
        "speed": 2.77,
        "deg": 160.001
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-18 18:00:00"
    },
    {
      "dt": 1505768400,
      "main": {
        "temp": 301.827,
        "temp_min": 301.827,
        "temp_max": 301.827,
        "pressure": 1000.53,
        "sea_level": 1027.01,
        "grnd_level": 1000.53,
        "humidity": 62,
        "temp_kf": 0
      },
      "weather": [
        {
          "id": 802,
          "main": "Clouds",
          "description": "scattered clouds",
          "icon": "03d"
        }
      ],
      "clouds": {
        "all": 44
      },
      "wind": {
        "speed": 3.17,
        "deg": 163.001
      },
      "rain": {
        
      },
      "sys": {
        "pod": "d"
      },
      "dt_txt": "2017-09-18 21:00:00"
    }
  ],
  "city": {
    "id": 4862034,
    "name": "Iowa City",
    "coord": {
      "lat": 41.6611,
      "lon": -91.5302
    },
    "country": "US"
  }
}

This is the 5 day forecast for where I live. I see that list is an array. I can then iterate over the list property on data like below:

  let forecast = []
  for (let item of data.list) {
    // get weather data at 12:00 P.M. for each day in 5 day forecast
    if (item.dt_txt.split(' ').pop().slice(0, 2) == 12) forecast.push(item)
  }
  return forecast
}

After writing this, I see you you forgot to parse JSON, maybe this will help someone else out!

1 Like

If you understand everything here, please mark one of the posts as solved so others know it’s been taken care of!

Thanks Isaac! I was trying for like an hour when I realized the return format was xml… xml…

1 Like