mailersend / mailersend-nodejs

The official MailerSend Node.js SDK
https://developers.mailersend.com
MIT License
136 stars 17 forks source link

TypeError: EmailObject is not a constructor #26

Closed haihuynhngoc closed 2 years ago

haihuynhngoc commented 2 years ago

I followed this tutorial to test mailersend-nodejs but there is an error message

const Recipient = require("mailersend").Recipient;
const EmailParams = require("mailersend").EmailParams;
const MailerSend = require("mailersend");

const mailersend = new MailerSend({
    api_key: "key",
});

const recipients = [
  new Recipient("your@client.com", "Your Client")
];

const emailParams = new EmailParams()
      .setFrom("your@domain.com")
      .setFromName("Your Name")
      .setRecipients(recipients)
      .setSubject("Subject")
      .setHtml("This is the HTML content")
      .setText("This is the text content");

mailersend.send(emailParams);
./node_modules/mailersend/src/modules/email.js:5
    let emailObject = new EmailObject(emailParams)
                      ^

TypeError: EmailObject is not a constructor
    at MailerSend.send (./node_modules/mailersend/src/modules/email.js:5:23)
    at Object.<anonymous> (./index.js:33:12)
emmanuelvlad commented 2 years ago

Versions 1.2.0 and above are broken because of this

me-shaon commented 2 years ago

@haihninit thanks for reporting the issue and providing the fix. The PR is merged and new version 1.3.1 is released with this patch.