1

##what will happen if i dont add this line to my express code.

app.use(bodyParser.urlencoded({ extended: true }));

  • 2
    Does this answer your question? [What does body-parser do with express?](https://stackoverflow.com/questions/38306569/what-does-body-parser-do-with-express) – shamon shamsudeen Jan 09 '20 at 13:12

2 Answers2

2

It supports parsing of application/x-www-form-urlencoded post data

If you don't add this line you won't be able to parse the body of requests with application/x-www-form-urlencoded content type

Mickael B.
  • 4,755
  • 4
  • 24
  • 48
2

Essentially, this lets you interact with forms sent with the application/x-www-form-urlencoded content-type much easier within express.

You can simply use the req.body.ELEMENT_NAME with these types of forms. This allows for interaction with more modern browsers that use this content-type when submitting a form. It is extremely beneficial for compatibility and I would recommend using it.

Rocksmash
  • 93
  • 1
  • 8