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: