Complete the code to create a catch-all route using app.all.
app.[1]('*', (req, res) => { res.send('Catch-all route'); });
app.all matches all HTTP methods for the given path, making it perfect for catch-all routes.
Complete the code to create a catch-all middleware using app.use.
app.[1]((req, res) => { res.status(404).send('Not Found'); });
app.use without a path acts as a catch-all middleware for any request not handled earlier.
Fix the error in the catch-all route that should handle all HTTP methods for any path.
app.[1]('*', (req, res) => { res.send('This is a catch-all route'); });
app.all is the correct method to handle all HTTP methods on a route.
Fill both blanks to create a catch-all middleware that sends a 404 status and message.
app.[1]((req, res) => { res.status([2]).send('Page not found'); });
app.use adds middleware. Sending status 404 means the page was not found.
Fill all three blanks to create a catch-all route that logs the method, path, and sends a 404 response.
app.[1]('*', (req, res) => { console.log(req.[2], req.[3]); res.status(404).send('Not Found'); });
app.all handles all methods. req.method and req.path give the HTTP method and path requested.