Timestamp Microservice | Tests failing

Last 2 tests are failling, even though they return exactly what is being asked.

It should handle an empty date parameter, and return the current time in unix format
It should handle an empty date parameter, and return the current time in UTC format


app.get("/api/timestamp/", function(req,res) {
      let date = new Date();
      res.json({ unix: date.getTime(), utc: date.toUTCString() });


User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36.

Timestamp Microservice (APIs and Microservices Projects)


Thanks in advance!

You have not specified a date parameter in the route, so how can you even check if one is missing? You might want to review this challenge.

Also, you should post a link to your project code.

1 Like

Hi. thanks for the answer!
I’m calling app.get twice, one for the route: "/api/timestamp/" and another one for "/api/timestamp/:date_string", which is recommended in the challenge solution.

Code link:

No need to create two routes. You can have a single route. You can read more about routes here.

1 Like

Link doesn’t work. I merged both routes into one anyways. Researched online and learnt about “optional parameters” (adding ?). Still doesn’t work.

Sorry about the link not working the first time. I have fixed the link, so try it again.

Thanks. Already optimized code and works same as before, or at least it gives same output which is what the tester looks for i think, since it doesn’t have access to the code. I’m going to keep reading and testing.