I am able to write code using node and express for the below request:
http://localhost:8000/users/1
The code is :
const express = require('express')
const app = express()
app.get('/users/:userId', (req, res) => {
res.send(req.params)
})
I want to do the same using http module:
var http = require('http');
//create a server object:
let server = http.createServer(function (req, res) {
res.write('Hello World!'); //write a response to the client
res.end(); //end the response
}).listen(8000); //the server object listens on port 8080
What is the correct approach for this?