【问题标题】:Node/Mongoose not sending SendGrid email due to mongoose promise warning由于猫鼬承诺警告,节点/猫鼬不发送 SendGrid 电子邮件
【发布时间】:2017-12-28 19:39:13
【问题描述】:

当我升级到 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: http://mongoosejs.com/docs/promises.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,对吧?

那行在这里: https://github.com/sendgrid/sendgrid-nodejs/blob/master/packages/client/src/client.js#L124

知道如何解决吗?我想我会回滚两者,直到我更好地理解问题!提前致谢!

【问题讨论】:

  • mongoose 和 sendgrid 是不相关的东西做不相关的功能。
  • 另外,请考虑 mongoose mpromise depreciation 警告,并像 bluebird 一样插入您选择的 promise 库。

标签: node.js mongodb mongoose sendgrid sendgrid-api-v3


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2016-11-03
    • 2015-11-19
    • 1970-01-01
    • 2015-05-12
    • 2012-12-14
    • 2017-06-15
    • 2019-06-04
    • 2017-08-18
    • 2019-02-13
    相关资源
    最近更新 更多