I'm actually working on a NodeJS API that send mail.
index.handlebars is a template that I want to use everytime that I need to send an email
So I use Node File Systeme (fs) to readFileSync() and then replace() the data need before sending email to the user.
Here is an exemple :
const readMe = fs.readFileSync('./mails/index.handlebars', 'utf8', (error, data) => {
if (error) {
console.log(error);
} else {
data = data.toString('utf8').replace('{%CONFIRMATION%}', "SELLER AS VALIDATE YOUR ORDER")
return data
}
})
console.log(readMe);
First sometimes, replace() is not working for me and nothing happend. I don't know why.
But when it work, my goal is to not overwrite index.handlebars. What I mean by that is replace() all the stuff and then send it BUT keep index.handlebars as it was before replace().
Is it possible ?
Thanks a lot.