nodejs bodyparser form data code example

Example 1: nodejs bodyparser form data

var bodyParser = require('body-parser');
var multer = require('multer');
var forms = multer();

// apply them

app.use(bodyParser.json());
app.use(forms.array()); 
app.use(bodyParser.urlencoded({ extended: true }));

// how to use

router.post('/', function(req, res) {
    console.log(req.body);
    console.log('received the widget request');
});

Example 2: how to get data send from a form express

const express = require('express')
const app = express()

app.use(express.urlencoded())

Tags:

Misc Example