What is Middleware? It is those methods/functions/operations that are called BETWEEN processing the Request and sending the Response in your application method.
When talking about
express.urlencoded() think specifically about POST requests (i.e. the .post request object) and PUT Requests (i.e. the .put request object)
You DO NOT NEED
express.urlencoded() for GET Requests or DELETE Requests.
express.urlencoded() for POST and PUT requests, because in both these requests you are sending data (in the form of some data object) 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 provides you with middleware to deal with the (incoming) data (object) in the body of the 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:
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:
extended option allows to choose between parsing the URL-encoded data with the
querystring library (when
false) or the
qs library (when
true). 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 querystring module provides utilities for parsing and formatting URL query strings.
A querystring parsing and stringifying library with some added security.