用node.js来写服务器接口,引入了bodyParser 但是,body里面拿不到前端传过来的数据
app.js文件
const express = require('express');
const app = express();
const path =require('path');
const router =require('./router.js')
const bodyParser =require('body-parser');
app.listen(4000,()=>{
console.log('server is running...')
})
// 配置模板引擎
app.engine('html',require('express-art-template'));
// 配置静态资源托管
app.use('/public',express.static(path.join(__dirname,'view','public')));
// app.use(router);
//挂载bodyParser
app.use(bodyParser.urlencoded({extended:false}));
app.use(bodyParser.json());
app.use(router);
req.body是空的 ,里面的数据是undefined
有哪位可以帮忙给看一下