webpack中使用devServer接收POST请求传来的值

webpack中使用devServer接收POST请求传来的值

const bodyParser = require('body-parser')
...
module.exports = {
    
    
    devServer: (app) => {
    
    
        app.use(bodyParser.json())
        app.post('/api/getList', (req, res) => {
    
    
	        console.log(req.body)
	        res.send({
    
    
	        	code: '000',
	        	msg: "请求成功"
	        })
        })
    }
}

猜你喜欢

转载自blog.csdn.net/Y_X_gang/article/details/112608599