Getting error in Mailjet nodemodule in reactjs

56 views Asked by At

I am encountering the following error: "The requested module '/node_modules/.vite/deps/node-mailjet.js?v=523d8493' does not provide an export named 'default'."

Initially, I downloaded the 'node-mailjet' npm package and implemented all the code provided in the documentation. However, when I attempt to run the code, it consistently throws this error. I've been frustrated searching for a solution online. Could someone please help me?

import Mailjet from 'node-mailjet';
// const Mailjet = require(['node-mailjet']);

const API_KEY = '******';
const API_SECRET = '******';

const mailjet = new Mailjet({
  apiKey: API_KEY,
  apiSecret: API_SECRET,
});

const sendEmail = async () => {
  // const mailjetClient = Mailjet.apiConnect(API_KEY, API_SECRET);

  const request = mailjet.post('send', { version: 'v3.1' }).request({
    Messages: [
      {
        From: {
          Email: '[email protected]',
          Name: 'Mailjet Pilot',
        },
        To: [
          {
            Email: '[email protected]',
            Name: 'passenger 1',
          },
        ],
        Subject: 'Your email flight plan!',
        HTMLPart: '<h3>Dear passenger 1, welcome to <a href="https://www.mailjet.com/">Mailjet</a>!</h3><br />May the delivery force be with you!',
      },
    ],
  });

  try {
    const response = await request;
    console.log(response.body);
  } catch (error) {
    console.log('MAILJET ERROR', error.message);
  }
};

export default sendEmail;
0

There are 0 answers