最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

由于mongoose promise警告,NodeMongoose没有发送SendGrid电子邮件

运维笔记admin9浏览0评论

由于mongoose promise警告,Node / Mongoose没有发送SendGrid电子邮件

由于mongoose promise警告,Node / Mongoose没有发送SendGrid电子邮件

当我升级到mongoose 4.13.8和sendgrid 6.1.4时,我收到此错误。试图了解如何解决我的问题,或者我是否需要恢复到以前版本的一个或两个?

(node:4862) DeprecationWarning: Mongoose: mpromise (mongoose's default promise library) is deprecated, plug in your own promise library instead: .html
(node:4862) UnhandledPromiseRejectionWarning: Error: Unauthorized
at Request.http [as _callback] (node_modules/@sendgrid/client/src/client.js:124:25)
at Request.self.callback (node_modules/request/request.js:186:22)
at Request.emit (events.js:159:13)
at Request.<anonymous> (node_modules/request/request.js:1163:10)
at Request.emit (events.js:159:13)
at IncomingMessage.<anonymous> (node_modules/request/request.js:1085:12)
at Object.onceWrapper (events.js:254:19)
at IncomingMessage.emit (events.js:164:20)
at endReadableNT (_stream_readable.js:1062:12)
at process._tickCallback (internal/process/next_tick.js:152:19)
(node:4862) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:4862) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

违规线似乎来自node_modules/@sendgrid/client/src/client.js:124:25,对吧?

那条线在这里:.js#L124

知道怎么解决?我想我会回滚两个,直到我更好地理解这个问题!提前致谢!

回答如下:

我找出了这个问题的原因。我猜“在线之间阅读”你可以看到Error: Unauthorized。无论出于何种原因,process.env.SENDGRID_API_KEY线对我不起作用。当我把实际的密钥放在那条线sgMail.setApiKey(_MYKEY_);时,它就开始工作了。

发布评论

评论列表(0)

  1. 暂无评论