Tell us what’s happening:
In this challenge my code did not work, so I try to use the one given in the hint page but it still not working I got these two failed :
The /now endpoint should have mounted middleware
The /now endpoint should return a time that is +/- 20 secs from now
Your code so far
var express = require('express');
var app = express();
var absolutePath = __dirname + "/views/index.html";
app.get('/now', (req, res, next) => {
req.time = new Date().toString();
next();
}, (req, res) => {
res.send({
time: req.time})
});
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36.
Challenge: Chain Middleware to Create a Time Server
I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.
Correct me if I’m wrong here, it seems to me that you are returning the current time, however, the second hint wants you to either add or remove 20 seconds from the current time:
Disclaimer: I haven’t tried my solution so I can’t give an guarantee that it will solve it. Hope it helps!
Hi everybody,
I let a link open today of my /now endpoint, cause I still have the same issue, if someone could help me please https://boilerplate-express-1.miles8012.repl.co/now
Thanks for your time and have a nice day
I made a new post about this issue yesterday, I didnt see this post. I have the same issue as you, and I fear it may be bugged, like the “Use the .env file” is bugged. I read in previous forum posts about this problem that some people have had success changing their time zones or adding seconds to the new Date() string. I tried all of these suggestions with no success, though several people in the thread did pass the test in this way.
I try but still have the same issue, and i still get the first error :
“The /now endpoint should have mounted middleware”
Did it solve the problem for you ?