seeh
March 10, 2023, 2:49pm
1
Tell us what’s happening:
All tests fails:
The /now endpoint should have mounted middleware
The endpoint should return the current time.
My source:
app.get(
"/now",
(req, res, next) => {
req.time = new Date().toString();
next();
},
(req, res) => {
res.send(
{ time: reg.time }
);
}
);
Your project link(s)
boilerplate-express - Replit
** got help from here: **
The /now endpoint should return a time that is +/- 20 secs from now
tried solutions here and here with the same result.
my guess was that there’s a time zone difference so I tried: ETC/GMT+1, -1, +2, -2 … which didn’t do the trick.
Your browser information:
User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/110.0
Challenge: Basic Node and Express - Chain Middleware to Create a Time Server
Link to the challenge:
seeh:
{ time: reg.time }
This could be your problem.
seeh
March 10, 2023, 2:59pm
3
seeh:
{ time: reg.time }
same errors if i use:
res.send({ "time": reg.time });
Yes, you will still fail, because the code is still incorrect.
What is reg.time
?
seeh
March 10, 2023, 3:03pm
5
igorgetmeabrain:
What is reg.time
?
at the console this gives me no output:
req.time = new Date().toString();
cosole.log('time=' + reg.time);
reg.time
is incorrect code. So is cosole.log
, but that’s another thing.
1 Like
seeh
March 10, 2023, 3:16pm
7
same errors with this updates and still no output at console with console.log :
app.get(
"/now",
(req, res, next) => {
let timeStr = new Date().toString();
req.string = timeStr;
console.log('timeStr=' + timeStr); // no output. idk why
next();
},
(req, res) => {
res.send({ "time": req.string });
}
);
I just forked your repl and it passes for me. I don’t know why it’s not passing for you, sorry.
When I visit your ‘/now’ endpoint, I get an error ‘reg is not defined’.
Perhaps if you exit replit and then log back in again, it will have updated to your current code?
I just forked your replit and ran it. I get no errors, see the result of the console.log, and all the tests pass.
Make sure you stop and restart the server before submitting the url again. Also, what is the exact url you are submitting?
1 Like
seeh
March 10, 2023, 3:54pm
10
i always jump to
boilerplate-express - Replit
in my web-browser.
then i copy the url from the top right https://boilerplate-express.sl5net.repl.co
copy it into the back-end-development-and-apis/basic-node-and-express/chain-middleware-to-create-a-time-server
and then…
but now it works
what i did. i was at kitchen was drinking something.
thats very strange.
is there a reason for latency? at the moment i also could use mobile-fon conection. something to do whit it.