Marek M
Marek M

Reputation: 87

Could you please the option(extended: false) used in express.urlencoded?

I was looking for an answer but didn't find proper one. Could you please explain me the difference between omitting the extended option and including it with the value of false? Also why do we have to provide express.urlencoded?Thanks.

app.use(express.urlencoded({extended: false}))

Upvotes: 1

Views: 435

Answers (1)

Hackbyrd
Hackbyrd

Reputation: 456

There are two main node modules used to parse query strings. Depending on what value you set the extended key (true - default or false), express will use that corresponding library.

  1. querystring - express.urlencoded({extended: false})
  2. qs - express.urlencoded({extended: true}) or express.urlencoded()

The “extended” syntax allows for rich objects and arrays to be encoded into the URL-encoded format, allowing for a JSON-like experience with URL-encoded.

The difference between the two are very minuscule and you shouldn't worry too much about it because they do the same thing. It's just a matter of the different syntax being used.

Upvotes: 4

Related Questions