mailjet / mailjet-apiv3-nodejs

[API v3] Official Mailjet API v3 NodeJS wrapper
https://dev.mailjet.com
MIT License
232 stars 67 forks source link

cant use .connect or .apiconnect #255

Closed xXTim97Xx closed 11 months ago

xXTim97Xx commented 11 months ago

const Mailjet = require('node-mailjet'); const mailjet = Mailjet.apiConnect(process.env.MJ_APIKEY_PUBLIC, process.env.MJ_APIKEY_PRIVATE);

I always receive errors like "Mailjet.apiConnect is not a function" or "Mailjet.connect is not a function"

ai-wintermute commented 11 months ago

Hi, @xXTim97Xx can you share a bit more context on the environment you're using? Node version, library version etc.

xXTim97Xx commented 11 months ago

Node Version: 15.8.0 React: 17.0.1 node-mailjet: 6.0.3

xXTim97Xx commented 11 months ago

image

You can also check my IntelliSense that it really is not shown here

ai-wintermute commented 11 months ago

So you're trying to use require in the client's code? You can't do this as it's part of the node CommonJS module system. Can you use import instead? As described here: https://github.com/mailjet/mailjet-apiv3-nodejs#send-email-example

xXTim97Xx commented 11 months ago

Yes, thanks a lot. This seems to work that way. But how do I use the proxy hack for testing?

I'm always receiving a CORS Error now

ai-wintermute commented 11 months ago

@xXTim97Xx it's because you need to set up your headers correctly to allow these cross-origin requests. You can read about them here: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS