john1
April 23, 2021, 9:20am
1
I am on this challenge:
I get this issue:
The /now endpoint should have mounted middleware
The /now endpoint should return a time that is +/- 20 secs from now
This is my code:
This is the output:
https://boilerplate-express.freecodecampdev.repl.co/now
Based on research I believe this is correct but why the issues? Help please.
Please use setTimeOut
var delayInMilliseconds = 1000; //1 second
setTimeout(function() {
//your code to be executed after 1 second
}, delayInMilliseconds);
I hope this will help you.
1 Like
john1
April 23, 2021, 9:30am
3
So like this:
var delayInMilliseconds = 1000; //1 second
app.get('/now', (req, res, next) => {
req.time = new Date().toString();
next()
}, (req, res) => {
setTimeout(function() {
//your code to be executed after 1 second
res.json({
'time': req.time
})
}, delayInMilliseconds);
});
Please use Date() function in setTimeout function.
john1
April 23, 2021, 12:37pm
5
Hey @mountian1992 I am still lost on this.
Your code is passing for me. Please make sure you are submitting the correct URL (without /now
).
https://boilerplate-express.freecodecampdev.repl.co
1 Like
john1
April 23, 2021, 5:43pm
8
Thank you again marked as the solution!
system
Closed
October 23, 2021, 5:43am
9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.