I am facing a challenge in handling an empty route parameter when a path is not specified. My intention is to return a new date if the route parameter is empty. However, the server's response so far is: Cannot GET /api/timestamp/
app.get("/api/timestamp/:date_string", function(req,res){
let dateString=req.params.date_string
if(!req.params.date_string){
dateString=new Date()
res.json({"unix": dateString.getTime(), "utc" : dateString.toUTCString()})
}
})
The current issue is that the server is not returning a JSON object with a new date as expected. Does anyone have any ideas on how to handle an empty route parameter?