Timestamp Microservice optional parameter

This pass locally but fail in replit

app.get("/api/:date?", function (req, res) {
  const dateString = req.params.date
  let date;
  if (!dateString) {
    date = new Date()
  } else {
    if (!isNaN(dateString)) {
      date = new Date(parseInt(dateString))
    } else {
      date = new Date(dateString)
    }
  }
  if (date.toString() === 'Invalid Date') {
    res.json({error: date.toString()})
  } else {
    res.json({unix: date.getTime(), utc: date.toUTCString()})
  }
});

errors:
An empty date parameter should return the current time in a JSON object with a unix key

An empty date parameter should return the current time in a JSON object with a utc key

bug?

Challenge: Timestamp Microservice

Link to the challenge:

Please post the link to your Replit.

here

Your code is passing for me. Are you submitting this URL?

https://boilerplate-project-timestamp.an00b1s.repl.co

it works with chrome on android :smiley:
(but fail with chrome and firefox on my arch based linux.)
User Agent is: Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0

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