Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with Nuxt3.rc12 or Nuxt3.rc13 projects #16

Closed
matej-marjanovic opened this issue Nov 10, 2022 · 1 comment
Closed

Not compatible with Nuxt3.rc12 or Nuxt3.rc13 projects #16

matej-marjanovic opened this issue Nov 10, 2022 · 1 comment

Comments

@matej-marjanovic
Copy link

Please update dependencies to Nuxt3 rc13.
Currently, the module is not compatible when adding it to a rc12 or rc13 Nuxt3 project.

Output Errors / Warnings:
1.

[h3] Implicit event handler conversion is deprecated. Use `eventHandler()` or `fromNodeMiddleware()` to define event handlers. 
     Route: /api/newsletter/subscribe 
     Handler: async (req, res) => {
  const { email } = await _file_home_projects_nuxt_starter_ad6gbk_node_modules_h3_dist_index_mjs.useBody(req);
  if (!email) {
    console.error("`[@nuxtjs/newsletter]` Missing `email` in the subscribe body");
    return;
  }
  const newsletterConfig = useRuntimeConfig().newsletter;
  const providerName = Object.keys(newsletterConfig)[0];
  try {
    const mailchimp = await 𝐢𝐦𝐩𝐨𝐫𝐭('file:///home/projects/nuxt-starter-ad6gbk/node_modules/@mailchimp/mailchimp_marketing/src/index.js').then((r) => r.default || r);
    mailchimp.setConfig({
      apiKey: newsletterConfig[providerName].apiKey,
      server: newsletterConfig[providerName].serverPrefix
    });
    let result;
    try {
      const response = await mailchimp.lists.addListMember(newsletterConfig[providerName].audienceId, {
        email_address: email,
        status: "subscribed"
      });
      result = { message: `Email ${response.email_address} subscribed to Mailchimp`, status: 200 };
    } catch (err) {
      result = { message: err.response.body.title, status: err.status };
    }
    res.statusCode = result.status;
    res.end(JSON.stringify(result.message));
  } catch (error) {
    res.statusCode = 500;
    res.end("Unexpected error occured", error);
  }
[POST] /api/newsletter/subscribe
2022-11-10T19:53:50.300Z	f5f840f8-0919-43bd-b554-2612317e490c	ERROR	[nuxt] [request error] [unhandled] [500] Cannot set properties of undefined (setting 'statusCode')
  at _BxWD19 (./chunks/nitro/vercel.mjs:442:20)  
  at processTicksAndRejections (node:internal/process/task_queues:96:5)  
  at async Object.handler (./node_modules/h3/dist/index.mjs:634:19)  
  at async Server.toNodeHandle (./node_modules/h3/dist/index.mjs:698:7)
@Baroshem
Copy link
Owner

@matej-marjanovic I have released a new version. It should work now :)

@Baroshem Baroshem closed this as completed Dec 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants