Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Unauthorized (401) Maximum credits exceeded #1032

Closed
LiubovBahatchenko opened this issue Jan 23, 2020 · 4 comments
Labels
status: duplicate duplicate issue

Comments

@LiubovBahatchenko
Copy link

LiubovBahatchenko commented Jan 23, 2020

I integrated sendGrid and everything worked fine, but now I receive the following error message below every time I try to send emails.
Although my limit was not exceeded (only 102 emails were sent this month, and a limit is 100 emails per day)

(node:2233) UnhandledPromiseRejectionWarning: Unauthorized (401)
  Maximum credits exceeded
    null
    null
    at Request.http [as _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:189:13)
    at Request.<anonymous> (node_modules/request/request.js:1161:10)
    at Request.emit (events.js:189:13)
    at IncomingMessage.<anonymous> (node_modules/request/request.js:1083:12)
    at Object.onceWrapper (events.js:277:13)
    at IncomingMessage.emit (events.js:194:15)
    at endReadableNT (_stream_readable.js:1125:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
(node:2233) 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:2233) [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.

The following code is used to send the email:

const sgMail = require('@sendgrid/mail');
const { SENDGRID_API_KEY } = process.env;

const forgotPasswordMail = (to, first_name, last_name) => {
  sgMail.setApiKey(SENDGRID_API_KEY);
  const msg = {
    to,
    from: '[email protected]',
    subject: 'Your password reset request',
    templateId: 'd-71746df705c44a8b9d5bb5c10d861754',
    dynamic_template_data: {
      first_name,
      last_name,
    }
  };
  sgMail.send(msg);
}

Technical details:

  • node version: v10.15.3
@childish-sambino
Copy link
Contributor

Closing as duplicate of #970

See my comment there to follow-up.

@sanmithapalanisamy
Copy link

Facing the same issue. Per day limit is also not reached but I receiving

ResponseError: Unauthorized
at node_modules/@sendgrid/client/src/classes/client.js:146:29
at processTicksAndRejections (node:internal/process/task_queues:94:5) {
code: 401,
response: {
headers: {
server: 'nginx',
date: 'Fri, 30 Jul 2021 07:43:50 GMT',
'content-type': 'application/json',
'content-length': '76',
connection: 'close',
'access-control-allow-origin': 'https://sendgrid.api-docs.io',
'access-control-allow-methods': 'POST',
'access-control-allow-headers': 'Authorization, Content-Type, On-behalf-of, x-sg-elas-acl',
'access-control-max-age': '600',
'x-no-cors-reason': 'https://sendgrid.com/docs/Classroom/Basics/API/cors.html',
'strict-transport-security': 'max-age=600; includeSubDomains'
},
body: { errors: [Array] }
}
} {
errors: [ { message: 'Maximum credits exceeded', field: null, help: null } ]
}

@JenniferMah
Copy link
Contributor

Hi @sanmithapalanisamy! SendGrid Support has the tools to help debug these kinds of issues. Please open a new support ticket to get help with this 401 error.

@chmsajid7
Copy link

I am facing the same issue: {"errors":[{"message":"Maximum credits exceeded","field":null,"help":null}]}

Any kind of help will be appreciated.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: duplicate duplicate issue
Projects
None yet
Development

No branches or pull requests

5 participants