Timestamp microservice project not passing

here is the code: ``` app.get("/api/timestamp/:timestamp", (req, res) => {
let timestamp = req.params.timestamp;
if(timestamp.match(/\d{5,}/)){
timestamp = +timestamp;
}
let date = new Date(timestamp);
if(date.toUTCString() == “Invalid Date”){
res.json({error: date.toUTCString()})
}
res.json({ unix: date.valueOf(), utc: date.toUTCString() });
});

app.get("/api/timestamp/", (req, res) => {
let date = new Date();
res.json({ unix: date.valueOf(), utc: date.toUTCString() });
}) ```

what am i doing wrong? pls help

It’s hard to debug without the errors you are seeing or a link to a project on repl.it or similar. Post a link to your project and you’ll get better advice.

This code is using the wrong API endpoints but I have no idea if that’s all the problems it has without the rest of the project.

1 Like

oh thanks…heres the link https://replit.com/@6ix-Ville/boilerplate-project-timestamp-4#server.js

It appears to be working now and passes the tests, but it is generating errors in the server console since you are not returning your responses (return res.json(...); etc.)

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