What does express.json() do?

Express basics and middleware · Freshers

Model answer

It is built-in middleware that parses incoming JSON request bodies and puts the result in req.body. Without it req.body is undefined. Set a size limit, for example express.json({ limit: '100kb' }), to avoid huge payloads.

Learn this topic

Express Middleware Explained: next(), Logging and express.json() in the course Node.js and Express: Build a Back End API from Scratch.

Sign in to add your own answer.

More questions