List array inside OpenWeatherMap for a five-day forecast react weather is showing hourly temperature only

Hi, guys. I’m trying to make the weather app using react and I need to get the weather forecast for the next 5 days and route through them, but I’m receiving only the hourly temps for today: happy-fire-7fke0 - CodeSandbox

Your API request gets data every 3rd hour during the next 5 days. The cnt parameter set to 5 limits the number of data records to 5. This means that you get the forecast until the next 4*3 = 12 hours after the datetime from the first data record.

To get data for at least the next 5 days, I would suggest to set cnt=40, since 5 days of data will generate 5*(24/3) = 40 records. One day equals 24 hours, but you only get data every 3rd hour, so you get 24/3 = 8 data records per day.

When you loop through your records, you can e.g. calculate a low average (night hours) and a high average (day hours) and a mid-day temperature (around 1pm or 2pm in the searched city’s local time).

If you want to manually examine a timestamp from the data, here is a good site that converts the timestamp to GMT and your time zone:

1 Like