nodejs express module code example
Example 1: node.js express
const express = require('express')
const app = express()
const port = 3000
app.get('/', (req, res) => res.send('Hello World!'))
app.listen(port, () => console.log(`Example app listening at http://localhost:${port}`))
Example 2: node js express
basic server
const express =require('express');
const app = express();
const PORT = 5000;
app.get('/',(req,res)=>{
res.json({message: 'Welcome to the backend'})
})
app.listen(PORT ,()=>console.log(`Connected to ${PORT}`)