HTTP Method Mayhem
Express Route Room
Status Code Street
100

This HTTP method reads all tasks from /api/tasks.

What is GET?

100

Add this middleware line so Express can read JSON request bodies.

What is app.use(express.json());?

100

A successful POST that creates a new task should return this status code.

 What is 201?

200

This HTTP method creates a new task.

What is POST?

200

In a POST route, the submitted JSON body appears on this Express object.

What is req.body?

200

Empty POST bodies should return this status code because the client sent bad data.

What is 400?

300

This HTTP method updates one task at /api/tasks/:id.

What is PUT?

300

In /api/tasks/:id, this part of the route is a placeholder.

What is :id?

300

If the route exists but the requested task id does not, return this status code.

 What is 404?

400

This HTTP method removes one task at /api/tasks/:id.

What is DELETE?

400

Express stores the URL value from /api/tasks/:id here.

400

This Express chain sends both a 400 status and a JSON error body.

What is res.status(400).json(...)?

500

In “the URL is the address; the method is the verb,” this part tells the server what job to do.

What is the HTTP method?

500

This code turns the route id from a string into a number.

What is Number(req.params.id)?

500

The path exists, but no task matches the id. This kind of 404 comes from this source.

What is our route handler, or our code?

M
e
n
u