We’re currently using this package which seems to be wrapping the npm package for sendgrid (We’re not using 1.3 yet, so we’re not using npm packages just yet)
On the npm page they define an api key with sendgrid as follows:
var sendgrid = require('sendgrid')(sendgrid_api_key);
How would you do the same with a package that wraps an npm package or when using an npm package in 1.3 instead?
You can use require in meteor!
Yes, I’m using require now. However, once we switch over to 1.3, how would the require example look like with a normal import? How would I define the API key?
I would also like to see how NPM packages (and SendGrid specifically) are handled in the new 1.3 version of Meteor.
That would look like this with import:
import sendgridModule from 'sendgrid';
const sendgrid = sendgridModule(sendgrid_api_key);
The difference is, you have to name the function you import, versus being able to execute the result of
However, note that the require syntax works exactly the way you would expect in Meteor 1.3. So you don’t have to rewrite using import if you don’t want to.