express.json() and express.urlencoded() specifically used POST requests and PUT Requests objects.
You DO NOT NEED to use express.json() and express.urlencoded() for GET Requests or DELETE Requests.
express.json() and express.urlencoded() for POST and PUT requests, because in both requests you are sending data to the server and you are asking the server to accept or store that data (object), which is enclosed in the body (i.e. req.body) of that (POST or PUT) Request
express.json() is a method inbuilt in express to recognize the incoming Request Object as a JSON Object. This method is called as a middleware in your application using the code: app.use(express.json());
express.urlencoded() is a method inbuilt in express to recognize the incoming Request Object as strings or arrays. This method is called as a middleware in your application using the code: app.use(express.urlencoded());
body-parser to do the same thing. body-parser used to be part of express. body-parser is specifically for POST Requests and PUT Requests.
what is middleware?
Trending Tutorials