Fail to Chain Middleware to Create a Time Server

Fail to Chain Middleware to Create a Time Server

Am finding it difficult pass this challenge, can someone please help me out
This is my code:

app.get('/now', (req, res, next)=>{
    req.time = new Date().toString();
}, (req, res)=>{
        "time": req.time

In the route app.get('/now', ...) chain a middleware function and the final handler. In the middleware function you should add the current time to the request object in the req.time key. You can use new Date().toString() . In the handler, respond with a JSON object, taking the structure {time: req.time} .

Hey @ejejeokon :slight_smile:!

The code You post here should work, but the code I see on will not because it’s missing the correct endpoint (the ‘/now’ URL/endpoint). Could You verify that the code on Your glitch is exactly the same?

I have done that, but still not getting the test pass

This the link!/ejejeok?path=myApp.js:74:3

This Is the Error i get “The /now endpoint should return a time that is +/- 20 secs from now”

Hmm, I just tested Your code and it passes :stuck_out_tongue:.

I think you’re sharing the editor code view instead of the live app, which is the required one. Try copying and pasting the live app URL into the challenge:

  • On the upper left corner there is a Share button (on glitch), click that.
  • Then click on Live App
  • Click on Copy
  • Paste that link into the challenge.

Let us know if that works.

no is not working
am even surprise
i always copy the live app link

please can i see your code again?
This is the error i received The /now endpoint should return a time that is +/- 20 secs from now

Hmmm that’s just weird.

Is your date/time (on your computer) ok? It may have something to do with that.


This is what i’m having here now

i don’t know what i have done wrong.

This how i copy

what could the error??

O my God, i finally got it done.

The problem was from my PC time

I just pass the text now, thanks

1 Like

Yes i have set it now

I am having the same issue. what was the problem with your PC time? I am not following