farahat80/react-open-weather

Cannot read property 'dt' of undefined

Closed this issue ยท 13 comments

Anyone run into this?

Line 379 of ReactWeather.js

key: '_mapForecast',
	    value: function () {
	      function _mapForecast(daysData, lang) {

	        var comingDays = _utils2['default'].getNextDays(new Date());
	        var daysMapped = [];

	        // Getting data from each day
	        for (var i = 0; i < 4; i++) {

	          var dayDataFiltered = daysData.filter(function (item) {
	            return item.dt_txt.includes(comingDays[i]);
	          }); //7 or 8 data objects represnting a day
	          var dayMapped = {};

	          dayMapped.date = _utils2['default'].formatDate(dayDataFiltered[0].dt, lang); //

I have the exact same problem just a few days ago. It was working last week. error occurs even using the same code

Same issue :/

Same issue too!!!!!

Fixed here
#32

I forked this until #32 is merged. You can do npm install JohnAllen/react-open-weather to install this package with this simple fix.

Fix doesn't work for me.

The problem is that in ReactWeather.js getNextDays() there is a bug where "0" is added to the current month, and then 1 is added to that. But since the "0" is a string, when the month gets added it becomes a string as well. And then when the 1 is added it too gets concatenated on to the end of the string - instead of incrementing a numeric value. This ends up with dates like 2020-41-21 instead of 2020-05-21. Then the code blows up downstream.

I just used another implementation. I did the right decision because this ain't fixed yet, the pull request is still open.

I just used another implementation. I did the right decision because this ain't fixed yet, the pull request is still open.

which one?)

@VovaChampion FYI, I fixed the issue with 'dt undefined' over in my fork: https://github.com/mhonkanen/react-open-weather
I also fixed some of the issues with the forecast data.

https://github.com/mhonkanen/react-open-weather

yarn add https://github.com/mhonkanen/react-open-weather

@mhonkanen I have the same issue. may I know what did you made on the fork?

k-ahn commented

I too am getting this error. I am reluctant to use the fork given the general position on fixes - namely this fatal defect has been open since Jan