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

Bug: Resend not working with node v16 #20

Open
krshashwat opened this issue May 25, 2024 · 0 comments
Open

Bug: Resend not working with node v16 #20

krshashwat opened this issue May 25, 2024 · 0 comments

Comments

@krshashwat
Copy link

Issue

When i am using node v16 then it is throwing an error - ReferenceError: Headers is not defined

How to reproduce

use node version - v16.20.2

Code snippet

require('dotenv').config();
const { Resend } = require('resend');
const express = require('express');

const resend = new Resend(process.env.EMAIL_API_KEY);

const app = express();

app.get('/', async (req, res) => {
    try {
        const data = await resend.emails.send({
            from: 'Acme <[email protected]>',
            to: ['[email protected]'],
            subject: 'Hello World',
            html: '<strong>It works!</strong>'
        });
        console.log(data);
        res.status(200).json({ msg: 'email sent' });
    } catch (err) {
        console.log(err);
        res.status(400).json({ msg: 'email not sent' });
    }
});

const PORT = process.env.PORT || 8000;
app.listen(PORT, () => console.log('Server running on Port - ' + PORT));

Error Screenshot

image

Alternative Fix

I updated the node version to 18.13.0 and it worked.

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

1 participant