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

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

#1

Dear community,
Kindly assist regarding this challenge… it seems like a lot of persons got the same problem!!
i am sure that my code is correct, however it’s always mentioning that +/-20 sec error exist!!
here’s my code: plz assist!! it’s so frustrating!!

app.get("/now", function(req, res, next) {
req.time = new Date().toString();
next();
},function (req, res) {
res.json ({“time” : req.time}); // This will display “example” to the user
});


#2

I’m not sure why it’s not working. I copied and pasted your code into my solution and it seemed to work fine.


#3

Same here. Although I noticed you didn’t put the “express” vars above your code. Here’s mine:
var express = require(‘express’)
var app = express()
app.get("/now", function(req, res, next) {
req.time = new Date().toString();
next();
},function (req, res) {
res.json ({time : req.time}); // This will display “example” to the user
});
Hope this helps.


#4

different timr zones might be the reason :frowning: