When to use express.urlencoded() and express.json()

And why we use express.urlencoded() and express.json()?

The documentation for them seems pretty clear:

https://expressjs.com/en/api.html#express.urlencoded

https://expressjs.com/en/api.html#express.json

You’re very unlikely to use either of these middlewares directly in most cases, but rather the body-parser middleware instead, which decodes both urlencoded (form submissions) and json requests. If you had custom parsing needs, you might use one of the urlencoded or json middlewares directly.

3 Likes