2
Hello!
I have a question here, I’m doing a function that takes the data from the Database and sends an email with them, for example: 'Hello {{Name}}'. ({{Name}}) It would be the field that would come from the database.
I managed to get you the value of DB but when I put it in the email, it just looks like Object Promise. I need help with that.
I am using Node.JS and the database is Postgresql
let pool = new Pool (config);
async Function names () { Let destNome = await pool.query('SELECT destinatari_name FROM data') console.log(destNome.Rows[0]. destinatar_name) }
async Function prevEntrega() { Let destPrevEntrega = await pool.query('SELECT previsao_delivery FROM data') console.log(destPrevEntrega.Rows[10]. previsao_delivery) }
names(); prevEntrega();
var mailOptions = {
from: '[email protected]',
to: '[email protected]',
subject: 'Email teste',
html: 'Olá, seja bem-vindo' + nomes() + ', a previsão de entrega é' + prevEntrega() + '.
'
};
You can also enter the code that will use
mailOptions
?– Sergio
var nodemailer = require('nodemailer'); var Transporter = nodemailer.createTransport({ service: 'gmail', auth: { user: '[email protected]', pass: 'password' } });
– Eduardo Nunes