DEV Community

Cover image for Built a Simple Node.js Express API
Marie Otoo
Marie Otoo

Posted on

Built a Simple Node.js Express API

I decided to try my hand at API development and began with a beginner-friendly project. I built a simple API in a Node environment using Express. This API provided hands-on experience and practice in the field of backend development.

In this simple project:

  • An API was built with Node and Express
  • The API returned JSON data

To get started, I set up my code editor, VS Code, and made sure Node.js was installed. It can be checked by running in the terminal or bash:

node -v
npm -v

or downloaded from:


if not already installed.

I continued by typing:

npm init -y
npm install express cors

Cross-origin resource sharing (CORS) makes the browser interact easily with the backend. Then confirm the dependencies in the folder in your chosen text editor or VS Code.

Next, I created an index.js with the code below.

To run the app:

node index.js

and open

http://localhost:3000

in a browser to see the message, including the email and time.

This app:

  • Created a Node Express server
  • Enabled CORS, cross-origin requests
  • Created a "GET /" route
  • Returned a JSON response -Created a Node Express server

Top comments (0)