简体   繁体   English

使用 sendgrid npm 模块未处理来自 node.js 的 promise 拒绝错误

[英]Unhandled promise rejection error from node.js using sendgrid npm module

What might be the cause?可能是什么原因? Node is giving me unhandled promise rejection error what is wrong with the code.节点给我未处理的 promise 拒绝错误代码有什么问题。

The sendgrid module has been required successfully and the sendgrid API key has been set correctly but the code is still giving me error.已成功要求 sendgrid 模块并且已正确设置 sendgrid API 键,但代码仍然给我错误。


sgMail.send({
    to: 'somebody@gmail.com',
    from: 'somebodygmail.com',
    subject: 'This is my first creation!',
    text: 'I hope this one actually get to you'
})

try with:尝试:

sgMail.send({
    to: 'somebody@gmail.com',
    from: 'somebodygmail.com',
    subject: 'This is my first creation!',
    text: 'I hope this one actually get to you'
}).then(out=>console.log(out)).catch(e=>console.log(e))

You'll be able to identify the error.您将能够识别错误。 if not, then post the log to the question.如果没有,则将日志发布到问题中。

Edit:编辑:

possible cause:可能的原因:

from email is invalid来自email 无效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM