September 2017
Intermediate to advanced
450 pages
11h 24m
English
Some requests provide more than simple URL paths and query parameters to a web server. They might provide a whole request body that contains rich content. By default, Express comes preconfigured with a middleware library called body-parser that will read both JSON and URL-encoded form content. The values of this body content will be available on the request object as a body property:
route.post('/post', function (req, res) { if (!req.body) return res.sendStatus(400) res.send('New Post, ' + req.body.title)})
There are many complexities to consider when working with a large body content in HTTP requests. To learn more about body-parser and how to use it for reading body content in Express, check out the official documentation ...
Read now
Unlock full access