r/programminghelp • u/FortuneBull • Jan 06 '21
JavaScript Questions about express.json() and express.urlencoded()
Is there ever a scenario you would want extended: false instead of true as a parameter in urlencoded?
I understand urlencoded is used to parse URL encoded bodies and express.json() is used to parse JSON objects but why can't they combine the two? I've seen these are commonly used in tandem but are there some who would prefer to use one and not the other?
3
Upvotes
1
u/amoliski Jan 06 '21
It's most likely there as a "you don't need it until... you need it" kind of situations. An API you control is returning something that shouldn't be parsed out, and if the option wasn't there, there would be nothing you can do to override the default behavior.