GithubHelp home page GithubHelp logo

resend / resend-express-example Goto Github PK

View Code? Open in Web Editor NEW
12.0 1.0 2.0 50 KB

This example shows how to use Resend with Express

Home Page: https://resend.com/docs/send-with-express

License: MIT License

TypeScript 100.00%

resend-express-example's Introduction

Resend with Express

This example shows how to use Resend with Express.

Prerequisites

To get the most out of this guide, you’ll need to:

Instructions

  1. Define environment variables in .env file.

  2. Install dependencies:

npm install
# or
yarn
  1. Run Express locally:
npm run dev
  1. Open URL in the browser:
http://localhost:3000

License

MIT License

resend-express-example's People

Contributors

bukinoshita avatar dependabot[bot] avatar jayanratna avatar renovate[bot] avatar zenorocha avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

resend-express-example's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

npm
package.json
  • dotenv 16.4.4
  • express 4.18.2
  • @types/node 20.11.19

  • Check this box to trigger a request for Renovate to run again on this repository

Getting error "Headers is not defined" when calling Resend constructor (not backwards compatible from Node 18)

Im trying to setup Resend in an express project that is on Node version 17

Im on the latest version of Resend v2.0.0

When running the project I get an error saying:

"ReferenceError: Headers is not defined",
" at new Resend (/var/task/node_modules/resend/build/src/resend.js:34:28)",

The line referenced begins here:
... this.headers = new Headers({ Authorization: Bearer ${this.key}, 'User-Agent': userAgent, 'Content-Type': 'application/json', }); ...

where you're using the Headers interface of the fetch API. Unfortunately this is only supported in Node version 18 and greater. I don't think I saw anything in your documentation while getting setup that Node version 18 was a requirement. Will you ever offer some sort of backward compatibility?

When I clone this resend-express-example project I don't see this error, but it looks like the Resend version that gets downloaded is version 0.17.1 where the Headers interface isn't being used. What version was this implemented? Is it recommended that I roll back instead of waiting for support in the latest version?

There are lots of mistakes

  1. in pakage.json script says node index.js and that file doesnt even exist
  2. in pakage.json we should use type module because it allows to use import statements instead of const require
    Resend works only with import not with const require statements
    3)const resend = new Resend('re_123456789'); process.env.RESEND_API_KEY should be used here

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.