I have Cannot read property 'convertIntoCorrectDate' of undefined error.
I think when I call this.convertIntoCorrectDate, this refers to objectResa and not my component. I tried to call myComp.convertIntoCorrectDate instead but it triggers error too (myComp.convertIntoCorrectDate is not a function).
Do you know how I can call my function ?
class myComp extends Component{
constructor(props){
// this.convertIntoCorrectDate = this.convertIntoCorrectDate.bind(this);
}
fillBooking(responseJson){
var reservations = responseJson.reservations;
reservations.forEach(function(objectResa) {
var aResaEvent = {
id: objectResa.resa.ID,
start: this.convertIntoCorrectDate(objectResa.resa.start),
end: this.convertIntoCorrectDate(objectResa.resa.end)
};
console.log(aResaEvent);
});
}
convertIntoCorrectDate(date){
// code to be written
return "0";
}
```