Back End Development and APIs Projects - Timestamp Microservice

Tell us what’s happening:

Timestamp current time keeps failing, even though is correct

Your code so far

app.get(‘/api/:date?’, (req, res) => {
const { date } = req.params

if (!date) {
const now = new Date(Date.now());;
return res.json({ unix: now.getTime(), utc: now.toUTCString() });
}

const isUTCString = isNaN(date);
const formatDate = isUTCString ? date : Number(date);

req.time = new Date(formatDate);

if (isNaN(req.time.getTime())) {
return res.json({ error: “Invalid Date” });
}

res.json({ unix: req.time.getTime(), utc: req.time.toUTCString() });
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36 Edg/133.0.0.0

Challenge Information:

Back End Development and APIs Projects - Timestamp Microservice

Anybody who has the same problem with the testing trying running try running the express on your original command line system especially if you switched from windows to wsl.