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",

Hi, how are you doing?

', body:'Hi, how are you doing?' }, // callback function function(error, success){ console.log('Message ' + success ? 'sent' : 'failed'); } );

Problem courtesy of: Alex B


Operator precedence? Try:

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

Solution courtesy of: istruble

Node.js Recipes责编内容来自:Node.js Recipes (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 前端开发 » success ? ‘sent’ : ‘failed’ defaults to ‘sent’ for success = null. Why?

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录