🚀View more development courses and content at https://chriscourses.com/
Learn how to grab input fields’ values with jQuery, send them off to a node server, and then parse them into a readable format with body-parser.
When a POST request is sent to our server from an HTML form, our request object will contain a gigantic block of data which is lengthy and hard to read. Rather than being forced to pick and choose our data through this massive object, we can make use of the body-parser package to parse our form’s input values into a clean, succinct JSON object.
If you’re familiar with PHP, you can think of this as creating your own $_POST variable. You just need to set it up yourself since node doesn’t come with the functionality out of the box. The body-parser package comes packaged with projects scaffolded by the Express command line interface (CLI), so there’s a very good chance you’ll use it more than once in the future. Enjoy everyone.
Timeline:
0:46 - A visualization of what we’ll be implementing
1:19 - Grabbing the form data using jQuery
3:10 - Trying to grab our data without body-parser
4:09 - Implementing body-parser
6:04 - Why are there two body-parser use functions?
7:13 - How our post request looks with body-parser
Resources:
https://www.quora.com/What-exactly-do...
https://github.com/expressjs/body-parser
https://expressjs.com/en/guide/using-...
https://expressjs.com/en/starter/stat...
Beatz:
Immortal Beats - Oh Wee - Creative Commons
DK 64 - DK Gangsta Rap
For updates on the progress of chriscourses.com and future videos, join the Chris Courses mailing list at http://chriscourses.com.
Support Chris Courses Through Patreon:
--------------------------------------
/ chriscourses
Chris Courses Social:
---------------------
Twitter: / chriscourses
Facebook: / chriscourses
Instagram: / chriscourses
Christopher Lis Social:
-----------------------
Twitter: / christopher4lis
CodePen: http://codepen.io/christopher4lis