Complete the code to add a 404 handler middleware in Express.
app.use(function(req, res, [1]) { res.status(404).send('Page not found'); });
The third parameter in Express middleware is next, which passes control to the next middleware.
Complete the code to set the 404 status code before sending the response.
app.use(function(req, res, next) {
res.[1](404).send('Not Found');
});The status method sets the HTTP status code for the response.
Fix the error in the 404 handler to correctly handle unmatched routes.
app.use(function(req, res, next) {
res.status(404).[1]('Sorry, page not found');
});The send method sends the response body and ends the response properly.
Fill both blanks to create a 404 handler that renders a 'notfound' view with status 404.
app.use(function(req, res, next) {
res.[1](404);
res.[2]('notfound');
});First set the status with status, then render the view with render.
Fill all three blanks to create a 404 handler that logs the URL, sets status 404, and sends a message.
app.use(function(req, res, next) {
console.log('404 at: ' + [1]);
res.[2](404);
res.[3]('Page not found');
});Use req.url to log the full URL, status to set the status, and send to send the response.