wht's the role of
app.use(bodyParser.json());
app.use(bodyParser.urlencoded());
and what's the difference between bodyParser() and CookieParser()
body-parser is a body parsing middleware, which populates the req.body with (for example) the value of the parametres of a POST.
cookie-parser parses cookies and populates req.cookies with objects bidden to cookie names.
bodyParser.json() - a middleware used for going over POST request data, parse it into json on put it on req.body.
cookieParser() - a middleware that parse cookie header and populate req.cookies
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With