How to Create Route in Node JS Express JS?

About Us:

We are from free coder. We are a group of web developers who are passionate about web development. You can learn from us php, laravel, node js, vue js, react js and many other topic on web developement.
we are very happy to help you.
free coder

Today what you are going to learn:

Hi Brother,

In this tute, we will discuss how to create route in node js express js. you'll learn node js express routes lesson. you will learn node js simple route lesson. We will look at lesson of express js routing lesson. Hello Brother, Creating a basic lesson of node js routing lesson express.

In this lesson i will give you very simple lesson of get and post method route and show you output as well. so let's see step by step simple routing with node express lesson.

Create Node Project:

you can run bellow command to create node app.

mkdir my-request-app

cd my-request-app

npm init

Install Express:

npm install express

Create Server.js File

let's create server.js file with get and post route.

server.js

var express = require('express');

var app = express();

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

res.send("This is a simple lesson of routing with ItSolutionStuff.com!");

});

app.post('/hello', function(req, res){

res.send("You just called the post method with ItSolutionStuff.com!");

});

app.listen(3000, () => console.log(`App listening on port 3000`))

Result:-

Get Method

Post Method

thank you very much for following up with me.

Tags

Recent Posts

Related Posts