Timestamp Microservice test failing

I’m failing the last two testcases on the timestamp microservice projects even though it works very will … can anyone help?

code:

// empty date is given
app.get("/api/", (req, res) => {
  const date = new Date();
  res.json({ unix: date.getTime(), utc: date.toUTCString() });
});

//valid date is given
  app.get("/api/:date", (req, res) => {
    let dateValue = req.params.date;
    // checks if it's a number
    if (/^-?\d+$/.test(dateValue)) {
      dateValue = parseInt(dateValue);
    }

    const date = new Date(dateValue);
    if (date.getTime()) {
      res.json({ unix: date.getTime(), utc: date.toUTCString() });
    } else {
      res.json({ error: "Invalid Date" });
    }
});

link to repl:
https://replit.com/@MoroOwusu/boilerplate-project-timestamp#server.js

I assume you fixed this? It seems to be working?

1 Like

i haven’t fixed it. seems it works on other computers but not with mine. don’t know if it might be as a result of cached data or something. Thank you

submitted it using my phone and it worked

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