+ 2
First you need to initialise bodyParser like thatđ
const bodyParser = require('body-parser')
Then configure it like that đ
const jsonParser = bodyParser.json()
var urlencodedParser = bodyParser.urlencoded({ extended: true })
So in your url post đ
app.post("/login", urlencodedParser, (request, response)=>{
const email = req.body.email
//Some code
} )
+ 1
Express now has its own support
app.use(express.json())
app.use(express.urlencoded({ extended: true }))
And you can access it everywhere directly from the request object. Like so:
req.body