I have a nodejs issue here, and I really don't know why it happens.
Here is my code :
isInTimeSlot() {
return new Promise((resolve, reject) => {
var date = new Date()
var hour = date.getHours()
hour = (hour < 10 ? "0" : "") + hour
var min = date.getMinutes()
min = (min < 10 ? "0" : "") + min
if (hour >= this.followMinHour && hour <= this.followMaxHour) {
return resolve(42)
} else if (hour >= this.unfollowMinHour && hour <= this.unfollowMaxHour) {
return resolve(1337)
} else {
return reject()
}
})
}
checkProjectTimeSlot() {
return new Promise((resolve, reject) => {
var timer = setInterval(function() {
console.log('Checking if bot is in time slot')
this.isInTimeSlot()
.then((mode) => {
clearInterval(timer)
resolve(mode)
})
}, 5000)
})
}
So here are 2 simple methods of my ES6 class, and when I execute it, I have the following error:
this.isInTimeSlot()
^
TypeError: this.isInTimeSlot is not a function
Can you see the error?