Hi,
Not sure if this is an issue or a fault on my side, but i can't use sendgrid library : I'm having this exception : setApiKey is not a function
,
I'm using TypeScript 2.9.1 but I don't think the types are the problem.
Pretty straightforward :
import * as sendGrid from "@sendgrid/mail"
sendGrid.setApiKey($SENDGRID_API_KEY)
mail = { // some mail object }
sendGrid.send(mail)
Just like in the docs.
If someone could enlighten me, that'd be really appreciable,
Thanks,
Sorry,
I just mis-imported the module :
import sgMail from "@sendgrid/mail"
works fine
@Loriot-n you saved my day! I also mis-imported the module and have been looking at it all day, but now it works.
Thanks again!
@Loriot-n : Hi, how did you import like that?
I also use import sgMail from '@sendgrid/mail'
But when I tried to run with babel-node:
Error: Cannot find module '../sendgrid/mail'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/piavgh/Desktop/Dev/src/helpers/mail.js:3:1)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Module._compile (/Users/piavgh/Desktop/Dev/jetdyno/Code/performflow-api/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Object.newLoader [as .js] (/Users/piavgh/Desktop/Dev/jetdyno/Code/performflow-api/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:600:32)
[nodemon] app crashed - waiting for file changes before starting...
I resolved this by changing import * as sendgrid from '@sendgrid/client';
to const client = require('@sendgrid/client');
Most helpful comment
Sorry,
I just mis-imported the module :
import sgMail from "@sendgrid/mail"
works fine