I cannot find any documentation on express.json() and express.urlencoded(). What do each of them do exactly?
The json
and urlencoded
middleware are both part of bodyParser. This is what the README says:
bodyParser([options])
Returns middleware that parses both
json
andurlencoded
. Theoptions
are passed to both middleware.bodyParser.json([options])
Returns middleware that only parses
json
. The options are:
strict
- only parse objects and arrayslimit
<1mb> - maximum request body sizereviver
- passed toJSON.parse()
bodyParser.urlencoded([options])
Returns middleware that only parses
urlencoded
with the qs module. The options are:
limit
<1mb> - maximum request body size