I am using the node scheduler to schedule my jobs, but getting Null in return, and nothing is printed when I try with try and catch the block, but still job returns null.
const jobDate = new Date();
const jobTz = 'Indian/Reunion';
const job = schedule.scheduleJob({ date: jobDate, tz: jobTz }, function () {
console.log('Job Running');
});
If I do console.log(job) then get null. Not sure what the error is and why this is happening.
I found a solution for that, this issue occurs when we pass
{ date: jobDate, tz: jobTz }. To solve this error we can usemoment-timezonepackage.If we want to use timezone then this is best way to handle. Else we can directly pass
startDateTimein scheduler function.In response we can get like
job.nameto get unique job Id.