nodemailer pass json to template

0

I'm trying to pass a json to an html template to send with nodemailer, this already allows me to send mails perfectly, but I do not know how the json could go. This would be my code js:

readHTMLFile('routes/api_mail/report.html', function(err, html) {
var template = handlebars.compile(html);
var replacements = {
     username: [{nombre:'1'},{nombre:'2'},{nombre:'3'}]
};
var htmlToSend = template(replacements);
var mailOptions = {
    from: '"Prueba" <[email protected]>', // sender address
    to: '[email protected]', // list of receivers
    subject: 'Prueba', // Subject line
    text: 'Prueba', // plain text body
    html : htmlToSend
 };
smtpTransport.sendMail(mailOptions, function (error, response) {
    if (error) {
        console.log(error);
    }
});

});

This is the .html code: {{username}} This works when I only send a parameter in the array. Ideally, my html will finally send a list:
1
2
3
What are the data I sent from the js.

    
asked by holman sneyder 05.09.2018 в 08:00
source

0 answers