Reputation: 433
nodejs tells me Cannot read property 'cancel' of undefined when i want to exectue job.cancel()
var schedule = require('node-schedule');
test = schedule.scheduleJob({second: 2, hour:
dataA[0].on_h , minute: dataA[0].on_m, dayOfWeek:
timerSD.day}, function(){
console.log(now+': Timer automatic ON - SD: '+x+ "timer ID"+dataA[0].ID);
db.setStatus(x, 1);
});
test.cancel();
Upvotes: 0
Views: 591
Reputation: 433
I do a workaround with reschedule. This works:
test = schedule.scheduleJob({second: 3, hour: dataA[0].off_h , minute: dataA[0].off_m, dayOfWeek: timerSD.day}, function() {
console.log(now+': Timer automatic OFF - SD: '+x+ "timer ID."+dataA[0].ID);
db.setStatus(x, 0);
});
test.reschedule(true);
Upvotes: 0