In nodejs I have scheduled a CRON that is running every day at 10 AM to send the push notification. Now the issue is, every time when this CRON is triggering 2 notifications are being sent to the user's device. Here is my code
var job2 = new CronJob('00 00 10 * * *', (res) => { woStatusCheck(); }, null, true, 'Asia/Kolkata'); job2.start();
CodePudding user response:
You can check their documentation. 4th parameter of the constructor is named start
and by sending true
for it, it will run the job before exiting the constructor. Then calling your job.start()
runs it again. You either send false
at 4th parameter and use the .start()
or remove the .start()
and send true