Import sendgrid npm package

This is how node does it:
var sendgrid = require('sendgrid')('YOUR_SENDGRID_API_KEY');

How do I import this package with Meteor? I tried this, but it did not work:
import sendgrid from 'sendgrid';
sendgrid('YOUR_SENDGRID_API_KEY');

Thanks!

Hi, I haven’t tested it yet but How to set api_key of sendgrid without require seems to suggest it should be

import sendgridModule from 'sendgrid';

const sendgrid = sendgridModule(sendgrid_api_key);

I thought I would update this topic as it’s the first one I found when searching for the exact same thing!

Just a quick note (since I recently set up SendGrid myself…), require works in Meteor, but the way their npm package is written you actually have to say:

const sendgrid = require( 'sendgrid' ).SendGrid( YOUR_API_KEY );

That extra .SendGrid() caused a lot of bizarre-looking errors before I realized the issue :slight_smile: