Reputation: 1929
I feel want to cry stuck in this for hours.
why would this code return error of cannot read property overwrite_date' of undefined
?!
for (var i = 0; i < temp.length; i++) {
console.log(data[i]) //return 3 item, no null or undefined value at all
if(data[i]){
let date = moment(data[i].overwrite_date).format('YYYY-MM-DD');
}
}
Upvotes: 0
Views: 33
Reputation: 16675
You are iterating temp
instead of data
.
Change this:
for (var i = 0; i < temp.length; i++) {
To this:
for (var i = 0; i < data.length; i++) {
▲
Upvotes: 2