getting Unhandled Runtime Error Error: Network Error when running async function

Viewed 12

In next.js app I'm trying to use an async function in next.js page to send an email with Novu

I used the docs to add the nova function as so -https://docs.novu.co/overview/quick-start

import { Novu } from '@novu/node';

const novu = new Novu('My_API_KEY');
const Mail = () => {
    async function sendEmail() {
        await novu.trigger('good-first-issue', {
            to: {
              subscriberId: 'faarnnow1@gmail.com',
              email: 'faarnnow1@gmail.com',
              firstName: 'John',
              lastName: 'Doe',
            },
            payload: {
              name: 'Hello World',
              organization: {
                logo: 'https://happycorp.com/logo.png',
              },
            },
          });
    }
    return (
        <div>
            <button type='button' onClick={sendEmail}>Send</button>
        </div>
    );
}

export default Mail;
0 Answers
Related