Back End Development and APIs Projects - Timestamp Microservice

im trying to handle empty request parameters but it is not working.
here is the code.

app.get("/api/:date?", function (req, res) {
 if(!req.params){
   res.json({state:"empty"})
 }else{
   res.json({echo : "hey"})
 }
});

how do i get it to account for emty request params
Your browser information:

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

Challenge: Back End Development and APIs Projects - Timestamp Microservice

Link to the challenge:

Try logging req.params at the top of your route to see what it gets as input from the tests. That way you can see what values it has as the tests run and where they are stored in the object.

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