I have an odd query that has really stumped me.
I have created this Express middleware:
const express = require('express')
const bodyParser = require('body-parser')
var router = express.Router()
router.use(bodyParser.urlencoded({ extended: false }))
router.use(bodyParser.json())
app.use(router)
router.use((req, res, next) => {
console.log(req.body)
})
router.post((req, res) => {
...
})
Whever I try to log the body in the router.post, it logs the correct body. However, when I try to log it in the router.use (as shown above), it only returns an empty object. Any thoughts of how I can get the body in middleware? Thanks!
