Alex B Alex B - 9 months ago 30
Node.js Question

success ? 'sent' : 'failed' defaults to 'sent' for success = null. Why?

I'm playing around with emailing from nodeJS (using the nodemailer lib), and I'm currently hitting some timeouts on the whole mailing process. That's not the problem I'd need help with. The problem I do need help with is that success will be null when it hits the logging part, and sole.log('Message ' +that makes the whole console.log statement to output "sent". No "Message", no failed.

Any idea why?

// e-mail options
subject:"node_mailer test email",
html:'<p><b>Hi,</b> how are you doing?</p>',
body:'Hi, how are you doing?'
// callback function
function(error, success){
console.log('Message ' + success ? 'sent' : 'failed');


Operator precedence? Try:

'Message ' + (success ? 'sent' : 'failed')