My test is not passing

I’ve been working on the Basic node and express curriculum, precisely the Chain Middleware to Create a Time Server exercise but my test has not been passing and it is working giving the right result.

The exercise is hosted on repl.it
This is my code below:

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

Project link: https://boilerplate-express.devadeboye.repl.co/now

This is the error message from freeCodeCamp

The /now endpoint should have mounted middleware
The /now endpoint should return a time that is +/- 20 secs from now

The link you have is dead.

On first look, are you missing the closing curly brace and closing parenthesis for the res.send call?

not in the code, i must have mistakenly delete the closing tags while editing.

i think its dead because i didn’t add the /now endpoint. if you click the link now, you will see that its working but freeCodeCamp can’t somehow see it

Try using res.json instead.

1 Like

If that doesn’t work, please provide a link to the repl.

i use res.json but i’m still getting the same result. The link to the repl is below:

The code itself you have right now passes for me when I test it. But if I fork your project it fails.

Try uninstalling fcc-express-bground and re-adding it back.

  1. In the console npm uninstall fcc-express-bground

  2. Paste "fcc-express-bground": "https://github.com/freeCodeCamp/fcc-express-bground-pkg.git" back into the package.json and run it.

Try the submit again.

ok will do that now… thank you

Ah! you saved me… Thank you everyone, it has pass the test. I’m really grateful. I discovered that adding the slash at the end of the url when submitting the link too is important e.g
https://boilerplate-express.devadeboye.repl.co will not work except you add slash at the back

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.