Open
Description
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
Alternative Fix
I updated the node version to 18.13.0
and it worked.
Metadata
Metadata
Assignees
Labels
No labels