11 - Use body-parser to Parse POST Requests - Basic Node and Express - freeCodeCamp Tutorial
We can use the 'body-parser' module to extract inputs from forms. These will be added to the body field of the request, when we call body-parser's urlencoded() method, which we can then use to submit a POST request.
Link to challenge :
https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/use-body-parser-to-parse-post-requestsWritten Guide :
https://www.notion.so/ganeshh123/Use-body-parser-to-Parse-POST-Requests-e8208ec5637b4ac8acc0f8770c4372acFull Playlist for this course :
https://www.youtube.com/playlist?list=PLhGp6N0DI_1SdIZ3uhbXnKAq2UcICSnWSAll Writen Guides for this course :
https://www.notion.so/ganeshh123/dab5e189407244c793c2f32d066eee9fAll My Tutorials can be found at :
https://www.notion.so/Tutorials-Ganesh-H-293ea420d34a464f9a1907e0405b5f26Concepts:
bodyParser.urlencoded()
Returns middleware that only parses urlencoded bodies and only looks at requests where the Content-Type header matches the type option. This parser accepts only UTF-8 encoding of the body and supports automatic inflation of gzip and deflate encodings. A new body object containing the parsed data is populated on the request object after the middleware (i.e. req.body). This object will contain key-value pairs, where the value can be a string or array (when extended is false), or any type (when extended is true).
https://github.com/expressjs/body-parser#bodyparserurlencodedoptionsrequest.body
Contains key-value pairs of data submitted in the request body. By default, it is undefined, and is populated when you use body-parsing middleware such as express.json() or express.urlencoded().
https://expressjs.com/en/api.html#req.bodyapp.use()
Mounts the specified middleware function or functions at the specified path: the middleware function is executed when the base of the requested path matches path.
https://expressjs.com/en/api.html#app.use-————————————————————————————————————-
Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside a web browser. Node.js lets developers use JavaScript to write command line tools and for server-side scripting—running scripts server-side to produce dynamic web page content before the page is sent to the user's web browser.
Express.js, or simply Express, is a web application framework for Node.js. It is designed for building web applications and APIs. It has been called the de facto standard server framework for Node.js. Express runs between the server created by Node.js and the frontend pages of a web application. Express also handles an application's routing.
freeCodeCamp (also referred to as “Free Code Camp”) is a non-profit organization that consists of an interactive
...
https://www.youtube.com/watch?v=7iQLkJ3rEQo