When my program like this, the former middware can send string 'Hello world' to Postman.
app.use((req, res, next) => {
console.log(req.body);
res.send('Hello world');
next();
})
app.use(express.json());
})
But I don't know why when I put the test middleware after app.use(express.json()), it do not send anything. I use postman to send post request with raw data of type json.
OK, I just found that because my POSTMAN POST request use raw json with single quoted instead of double quoted. I changed it into double quoted so it worked. Thanks.