Typeerror: Cannot Read Property 'todate' Of Undefined
I have a firebase project, I am getting the below error log when running a firebase function, below are the error log and the code. the error is Cannot read property 'toDate' of u
Solution 1:
In your class instead of:
this.dateTime = dateTime.toDate().getTime()
do this.dateTime = dateTime && dateTime.toDate().getTime()
(or even safer: this.dateTime = dateTime && dateTime.toDate && dateTime.toDate().getTime()
)
OR you could solve it by using some default value like
this.dateTime = (dateTime || defaultValue).toDate().getTime()
Post a Comment for "Typeerror: Cannot Read Property 'todate' Of Undefined"