How to schedule email whit req.body and node-cron

元气小坏坏 提交于 2019-12-25 00:04:35

问题


i need to schedule email send, i'm using node-cron. i want to know how to use "req.body" for date and time to schedule.

i need help to resolve how insert in this part of code the req.body

cron.schedule('* * * * *')

and if useful to use

<input type="time">
<input type="date">

Thanks for all


回答1:


Since the node cron expression is string you can pass the variables in form of string something like

let c="0";
cron.schedule(`${c} * * * * *`, ()=>{ // you can use template literals to pass variable args
// your job runs every minute

})

Like wise you can pass different arguments according to your requirements. You can refer official documentation of node cron here-https://www.npmjs.com/package/node-cron



来源:https://stackoverflow.com/questions/55555493/how-to-schedule-email-whit-req-body-and-node-cron

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!