How to Create GET Route in Node JS Express JS?

Sep 12, 2022

.

Admin

How to Create GET Route in Node JS Express JS?

Hello Friends,

This tutorial is focused on how to create a get route in node js express js. In this article, we will implement a create get route in node js express js. it's a simple example of create get route in node js. we will help you to give an example of create a get route in node js using express js. Let's get started with node.js create a get route in node js using express js.

I will give you a simple example of create the get method route in node js. In this example create the GET method using express in node js.

So let's start following example with output:

Step 1: Install Node JS


This step is not required; however, if you have not created the node js app, then you may go ahead and execute the below command:

mkdir my-app

cd my-app

npm init

Step 2: Update server.js file

server.js

var express = require('express');

var route = express();

//this is a simple get route

route.get('/', function(req, res){

res.send("Hello Nicesnippets.com!");

});

route.listen(8000, () => console.log(`App listening on port 8000`))

Run Node App

node serevr.js

Open your browser and copy paste this URL:

http://localhost:8000/

Output:

I hope it can help you...

#Node.js Express

#Node JS