首页 > 解决方案 > 使用 sendgrid npm 模块来自 node.js 的未处理的承诺拒绝错误

问题描述

可能是什么原因?节点给了我未处理的承诺拒绝错误代码有什么问题。

已成功要求 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'
})

标签: javascriptnode.js

解决方案


尝试:

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))

您将能够识别错误。如果没有,则将日志发布到问题中。

编辑:

可能的原因:

来自电子邮件无效


推荐阅读