Я интегрирую sendgrid в мой node.js проект со следующим кодом согласно инструкциям на их сайте
const sgMail = require('@sendgrid/mail')
const sendGridAPIKey = "API key"
sgMail.setApiKey(sendGridAPIKey)
const msg = {
to: 'agrawalanuj751997@gmail.com',
from: 'agrawalanuj751997@gmail.com',
subject:'My first mail from node',
text:"I'm sending myself an email"
}
sgMail.send(msg)
В моем журнале появляется следующая ошибка. Я пробовал несколько ключей API для нескольких учетных записей, но все равно получаю ту же ошибку.
(node:16043) UnhandledPromiseRejectionWarning: Error: Forbidden
at Request._callback (node_modules/@sendgrid/client/src/classes/client.js:124:25)
at Request.self.callback (node_modules/request/request.js:185:22)
at Request.emit (events.js:200:13)
at Request.<anonymous> (node_modules/request/request.js:1154:10)
at Request.emit (events.js:200:13)
at IncomingMessage.<anonymous> (node_modules/request/request.js:1076:12)
at Object.onceWrapper (events.js:288:20)
at IncomingMessage.emit (events.js:205:15)
at endReadableNT (_stream_readable.js:1154:12)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
(node:16043) 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:16043) [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.