Basic Node and Express - Chain Middleware to Create a Time Server

Tell us what’s happening:

I am getting error => The /now endpoint should have mounted middleware
code=>

function middleware(req, res, next) {
req.time = new Date().toString();
next();
}
app.get(“/now”, middleware, function (req, res) {
console.log(req.time);
return res.json({ time: req.time });
});

###Your project link(s)

solution:

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36

Challenge Information:

Basic Node and Express - Chain Middleware to Create a Time Server

Hello @jaydeepp

I see there is already a similar post, have a look if there is something written on it which can help you.

already checked , but that solution is not working

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.