app.js
var express = require(\'express\')
, http = require(\'http\');
var app
An update on using the middleware, body-parser
, for later versions of Express: Using app.use(express.bodyParser())
will report an error such as:
Error: Most middleware (like bodyParser) is no longer bundled with Express and must be installed separately. Please see https://github.com/senchalabs/connect#middleware.
This can be addressed by first installing the body-parser middleware:
npm install body-parser
then write code such as:
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
and then accessing the body
of the request
object, for example, console.log(req.body)