employeesRouter.route('/newreview/:employeesId')
.put(cors.cors, (req, res, next) => {
var options = { format: 'Letter' };
var html = email.reviewStatus(
req.body.name,
req.body.review.date,
req.body.review.store,
req.body.review.effectiveDate,
req.body.review.currentRate,
req.body.review.newPayrate);
pdf.create(html, options).toFile(`./${req.body.review.store}status.pdf`, function (err, res) {
if (err) return console.log(err);
console.log(res); // { filename: '/app/status.pdf' }
});
console.log(req.body.review);
//add rating
setTimeout(function () {
const storeEmail = getEmail(req.body.review.store);
const score = req.body.review.score;
const mailDataPassChange = {
from: 'Wenventure Inc <[email protected]>', // sender address
name: 'Wenventure Inc',
to: req.body.email,
attachments: [
{
filename: `${req.body.review.store}status.pdf`,
path: `./${req.body.review.store}status.pdf`,
}
],
cc: storeEmail, // list of receivers
subject: `Your Performance Review -${req.body.review.date}`, // Subject line
text: `New Review!`, // plain text body
html: email.reviewMessage(`New Performance Review!`, req.body.name, req.body.review, score) // html body
};
transporter.sendMail(mailDataPassChange, function (err, info) {
if (err)
console.log(err)
else
console.log(info);
});
}, 5000);
Employee.findByIdAndUpdate(req.params.employeesId, {
$set: {
nextReview: req.body.nextReview,
lastReview: new Date(),
},
$push: { history: req.body.review }
})
.then((employees) => {
res.statusCode = 200;
res.success = true;
res.setHeader('Content-Type', 'application/json');
res.json(employees);
})
.catch((err) => next(err));
})
I need to create a pdf from the html and then send this report via node mailer. I dont need to store the pdf anywhere just need to attach it to an email and send.
This worked fine when it was on Heroku, but once I migrated to Vercel it wont work any more. Is it because I can’t create new files in vercel? If so, how do you do it?