Working with body-parser - Create a Newsletter Signup Form with Node.js - Ep. 5

Released on November 2nd 2016
Length: 07:56

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: Beatz: Immortal Beats - Oh Wee - Creative Commons DK 64 - DK Gangsta Rap For updates on the progress of and future videos, join the Chris Courses mailing list at Support Chris Courses Through Patreon: -------------------------------------- Chris Courses Social: --------------------- Twitter: Facebook: Instagram: Christopher Lis Social: ----------------------- Twitter: CodePen: