Sendgrid-nodejs: require(...).SendGrid is not a function

Created on 9 Aug 2016  ·  3Comments  ·  Source: sendgrid/sendgrid-nodejs

Issue Summary

_Using v3 Mail for Node.js._

In your documentation for v3 Mail, under "Node.js" code examples, you specify on _line 11_, to write

var sg = require('sendgrid').SendGrid(process.env.SENDGRID_API_KEY)

however, when I do, i receive TypeError: require(...).SendGrid is not a function with a pointer ^ (carat) at the period between ) and SendGrid(process.env.SENDGRID_API_KEY).

However, when I do this...

const sendGrid = require('sendgrid')(process.env.SENDGRID_API_KEY); //removing the .SendGrid method
console.log('sendGrid: ', sendGrid);

I receive NO error's and I can successfully send an email.

Please let me know if I have missed something, however, if I have not, you may consider updating your documentation to remove future confusion.

P.S.

SendGrid is awesome. Keep doin' good work.
-Tobiah Rex

  • sendgrid-nodejs Version: master (latest commit: 0df1613)
  • Node.js Version: 6.2.1
help wanted bug

Most helpful comment

I have updated the code example to match the new updates to this library: https://sendgrid.com/docs/Integrate/Code_Examples/v3_Mail/nodejs.html

There was a recent breaking change and I failed to update the docs at docs.sendgrid.com.

Thanks again!

All 3 comments

Hello @TobiahRex,

Thanks for the heads up!

We'll dig in and make the appropriate fixes.

I have updated the code example to match the new updates to this library: https://sendgrid.com/docs/Integrate/Code_Examples/v3_Mail/nodejs.html

There was a recent breaking change and I failed to update the docs at docs.sendgrid.com.

Thanks again!

Hi @thinkingserious,

Awesome to hear you were able to make the necessary changes. Thanks for the reply!

-Toby

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Loriot-n picture Loriot-n  ·  4Comments

thinkingserious picture thinkingserious  ·  4Comments

amlcodes picture amlcodes  ·  4Comments

agostonbonomi picture agostonbonomi  ·  3Comments

kiranshashiny picture kiranshashiny  ·  4Comments