Back End Development and APIs Projects - Timestamp Microservice

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:

What error do you get?

When I submit your project, it passes all tests.

Waiting:Your project can handle dates that can be successfully parsed by new Date(date_string)

Can you try a different browser or clear your browser cache?

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