Cancel node-schedule event after it has been set

后端 未结 2 941
我寻月下人不归
我寻月下人不归 2020-12-28 18:45

I am planning on using node-schedule to set up push notifications for appointment reminders as follows:

var schedule = require(\'node-schedule\');
var date =         


        
2条回答
  •  时光说笑
    2020-12-28 18:52

    var randf = require('randomstring');    
        var jobId = randf.generate(10); //randomsrting
        var at = new Date();
        var time = at.setSeconds(at.getSeconds() + Number(5))  //after 5 second     
        schedule.scheduleJob(jobId, new Date(time),function(){
             schedule.cancelJob(jobId);
             console.log('hi--viral');
         });
    

提交回复
热议问题