bodyparser express use code example
Example 1: body parser use
var express = require("express");
var app = express();
var bodyParser = require("body-parser");
app.use(bodyParser.urlencoded({extended: true}));
Example 2: urlencoded json express
var express = require('express')
var app = express()
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
app.post('/profile', function (req, res, next) {
console.log(req.body)
res.json(req.body)
})
Example 3: bodyparser
var bodyParser = require('body-parser')
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())
Example 4: app use body parser
app.use(bodyParser.json())