Helloo!! everyone, lets start build Rest Apis in our very first nodejs app.
Install and Setup Nodejs in your system from here đź”—Link
Open cmd terminal and write
$ mkdir test-app
$ cd test-app
$ npm init
and select your main file name as app.js
this will create the đź“„package.json. Now in the root directory create a file name đź“„app.js , now we need to install express
$ npm install express --save
now in app.js
const express = require('express');
const app = express(); // we will use this app to define routes, port, Middleware everything
//route
app.get('/', (req,res) =>{
res.send('Hello World');
});
// define port for hosting
app.listen(3004,()=>{
console.log("Port running on 3004")
})
now in terminal run command npm app.js