Express res.send
Once res.send() is used
no further operations are sent
console.log can be used multiple times but res.send can only be used once
const express = require("express");
const users = require("./MOCK_DATA.json");
const app = express();
const PORT = 3000;
app.use(
"/hi/:id",
(req, res, next) => {
console.log("HELLO ");
next();
},
(req, res, next) => {
console.log("Hellow 2");
next();
}
);
app.get("/hi/:id", (req, res, next) => {
res.send(req.params.id);
});
app.listen(PORT, () => {
console.log("server is running at port" + PORT);
});
Comments
Post a Comment