Complete the code to set the HTTP status to 404.
app.get('/notfound', (req, res) => { res.status([1]).send('Page not found'); });
The res.status() method sets the HTTP status code. 404 means 'Not Found'.
Complete the code to send a 201 status code after creating a resource.
app.post('/create', (req, res) => { // resource creation logic res.status([1]).send('Created'); });
201 means 'Created' and is used after successfully creating a resource.
Fix the error in setting the status code to 500 for server error.
app.get('/error', (req, res) => { res.status([1]).send('Server error occurred'); });
status(500) inside the argument.res.status(500) inside the argument.The res.status() method expects a number, not a string or a function call inside.
Fill both blanks to set status 403 and send a message 'Forbidden'.
app.get('/forbidden', (req, res) => { res.status([1]).[2]('Forbidden'); });
json instead of send when sending plain text.403 is the status code for 'Forbidden'. The send method sends the response body as text.
Fill all three blanks to set status 302, redirect to '/login', and end the response.
app.get('/redirect', (req, res) => { res.status([1]).[2]('/login').[3](); });
send instead of redirect.302 is the status code for redirect. redirect sends the redirect response. end ends the response process.