A route is a mapping from a url to an object.It handles HTTP client requests. Basic Routing Hope you have install and have basic knowledge Express module. npm install express Note: Above command download the required express modules and install them. Here is our Server file. var express = require( 'express' ); var app = express(); //Creating Router() object var router = express.Router(); // Provide all routes here, this is for Home page. router.get("/",function(req,res){ res.json({"message" : "Hello World"}); }); app.use("/",router); // Listen to this Port app.listen(3000,function(){ console.log("Live at Port 3000"); }); Code Explanation: 1. In our first line of code, include the "express module." 2. Create object of the express module. 3. Creating a callback function. This function call when you hit url from browser http://localhost:3000 .It send the string 'Hello World' to ...
Coding Cheatsheets - Learn web development code and tutorials for Software developers which will helps you in project. Get help on JavaScript, PHP, XML, and more.