Reputation: 7
I have a confusion while using the bodyparser.Why do we actually need bodyparser when we have json.stringify(to convert object to string) and json.parse(to convert JSON to object)
is it because using it in our app.use() automatically applies the middleware during the interchange of data between client and the server? and we don't need to specify each time when the sending the data from client to server and vice versa?
and if it is so what is the difference between urlencoded and json in bodyparser?
Upvotes: 0
Views: 385
Reputation: 944147
Why do we actually need bodyparser when we have json.stringify(to convert object to string)
The body parser is also responsible for reading the data from the network stream of the HTTP request in the first place. You can't parse data until you have it.
what is the difference between urlencoded and json in bodyparser?
They parse bodies written in different data formats. The urlencoded format is the default encoding format for a <form>
.
Upvotes: 0