Leave.create({
leaveType: leaveType,
fromDate: fromDate,
toDate: toDate,
emailId: emailId,
reason: reason,
reportTo: reportTo,
userId: userId
})
LeaveReq.create({
empName: userId,
appliedFrom: fromDate,
apliedTo: toDate,
leaveType: leaveType,
status: req.body.status,
reqTo: reportTo
})
.then(result =>{
transporter.sendMail({
to: EmpList.findOne({attributes:['profEmail'],where:{firstName: reportTo}}),
from: '[email protected],',
subject: 'You recieved a user request',
html: `<p>please check your app to take action on this request</p>
`
});
res.status(201).json({message: 'leave updated', userId: result.id, status: '1'})
})
.catch(err =>{
if(!err.statusCode){
err.statusCode = 500;
}
next(err);
});
我收到此错误
node:9440) UnhandledPromiseRejectionWarning: Error: Missing destination email
at Request._callback (D:\ct-work\cthrm_api\node_modules\sendgrid\lib\sendgrid.js:88:25)
at Request.self.callback (D:\ct-work\cthrm_api\node_modules\request\request.js:185:22)
at Request.emit (events.js:210:5)
at Request.<anonymous> (D:\ct-work\cthrm_api\node_modules\request\request.js:1161:10)
at Request.emit (events.js:210:5)
at IncomingMessage.<anonymous> (D:\ct-work\cthrm_api\node_modules\request\request.js:1083:12)
at Object.onceWrapper (events.js:299:28)
at IncomingMessage.emit (events.js:215:7)
at endReadableNT (_stream_readable.js:1200:12)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:9440) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function
没有障碍,或拒绝未处理的承诺使用.catch()。 (拒绝ID:1)(节点:9440)[DEP0018]DeprecationWarning:已弃用未处理的承诺拒绝。在未来,未处理的承诺拒绝将终止具有非零退出代码的Node.js进程。
建议在“至”部分中通过sql查询发送邮件的一些方法