My challenge fails using the response in the hint page

Hello all,

Thank you for your time

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

Link to the challenge:

1 Like

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.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

1 Like

Hi,
Thank you, I’ll be careful next time :slight_smile:

1 Like

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!

1 Like

that I think is just an error margin for slow tests, not that you need to add or remove 20s

1 Like

Hi everybody,

I still no have any clue why the code in the correction is not working, and i’m stuck and sad :slight_smile:

Thanks for your time,

Have a nice day

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 :slight_smile:
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.

Thanks for your answer,
I’ll try those stuff and let you know if it works for me. Hope we will find a way to pass it :slight_smile:
Have a good day

I even found an article, seems to be based on the forum answers.

Good luck!

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 ?

Nope, doesn’t work for me. Nor does the previous challenge, " Implement a Root-Level Request Logger Middleware".