express-post-json Flashcards

1
Q

What does the express.json() middleware do and when would you need it?

A

The express.json() middleware is a built-in middleware function of Express. It parses incoming requests with JSON data in the body of the request.
A new “body” object containing the parsed data is populated on the “request” object after the middleware (i.e. req.body), or an empty object if there is no data in the body of the request.

The express.json() middleware function would be used when you need to parse JSON request bodies.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly