0

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.

This is the code

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

David
  • 5,882
  • 3
  • 33
  • 44
  • 1
    Welcome to StackOverflow! Please add the code directly as code in your question, not as picture. That helps others to answer faster and easier. [Here is still a general guid for asking good questions](https://stackoverflow.com/help/how-to-ask). Thanks! – David Apr 07 '19 at 04:13
  • embedded picture, but it's always preferable to have it as text as it enables others to copy and paste for answers. – David Apr 07 '19 at 07:58
  • If I am not wrong req.body works on names so you need to have “ name “ attribute added to your inputs – LearningPhase Apr 07 '19 at 08:06

1 Answers1

0

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

Shubham Dixit
  • 9,242
  • 4
  • 27
  • 46