Open krshashwat opened 6 months ago
When i am using node v16 then it is throwing an error - ReferenceError: Headers is not defined
ReferenceError: Headers is not defined
use node version - v16.20.2
v16.20.2
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 <onboarding@resend.dev>', to: ['kumarshashwat62@gmail.com'], 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));
I updated the node version to 18.13.0 and it worked.
18.13.0
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
Error Screenshot
Alternative Fix
I updated the node version to
18.13.0
and it worked.