Tell us what’s happening:
I am getting this error.
Your project link(s)
app.get("/api/:timestamp", function (req, res) {
let timestamp = req.params.timestamp;
// console.log(timestamp);
if (!timestamp.match(/-/g)) {
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", function (req, res) {
let date = new Date();
res.json({ unix: date.valueOf(), utc: date.toUTCString() });
});
solution: Glitch :・゚✧
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36
Challenge: Back End Development and APIs Projects - Timestamp Microservice
Link to the challenge: