Timestamp Microservice - "handle an empty date parameter"

I’ve completed all the task except for the empty parameter.

Here is my code:

app.get(“/api/timestamp/”, (req, res) => {
const date = new Date();
res.json({
unix:date.getTime(),
utc:date.toUTCString()
});
});

Or…

app.get(“/api/timestamp/”, (req, res) => {
res.json({
unix: Date.now(),
utc: Date() })
});

I tried both method above but still doesn’t work.

Here’s the rest of the code:

// this tasks is complete
app.get(“/api/timestamp/:date_slug”, (req, res) => {
const { date_slug } = req.params;
const date = new Date(date_slug);
const timeStamp = Number(date_slug)
const timeStampToDate = new Date(timeStamp)

if(timeStampToDate.toUTCString() !== “Invalid Date”){
return res.json({
unix:timeStamp,
utc:timeStampToDate.toUTCString()
});
}

if (date.toUTCString() === “Invalid Date”) {
return res.json({
error: “Invalid Date”
});
} else {
res.json({
unix: date.getTime(),
utc: date.toUTCString()
});
}
});

Problem:

// running tests
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
// tests completed

Link to the challenge:
[https://www.freecodecamp.org/learn/apis-and-microservices/apis-and-microservices-projects/timestamp-microservice]

In the challenge example my code works the same but fcc still yells at me please help.

Hello there,

For future reference, when you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

As for your question, I suggest you take a look at the tests, as they will provide insight as to what you are expected to return.

We are aware of a few issues with the backend projects instructions not being up-to-date with the tests.

Here are the tests: https://github.com/freeCodeCamp/freeCodeCamp/blob/master/curriculum/challenges/english/05-apis-and-microservices/apis-and-microservices-projects/timestamp-microservice.english.md

Hope this helps

Thank you for the advice this is my first time posting on this forum and the editor is like the markdown previewer project that i build in the front end curriculum but really don’t know how this works.
I will check the link you gave me thank you again.