Tell us what’s happening:
I write my code like this
function timeMiddleware(req, res, next) {
req.time = new Date().toString();
next();
}
app.get(‘/now’, timeMiddleware, function(req, res) {
res.json({ time: req.time });
});
but i could not pass the
Failed:The /now endpoint should have mounted middleware
Your project link(s)
solution: boilerplate-express - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36
Challenge: Basic Node and Express - Chain Middleware to Create a Time Server
Link to the challenge: