标签:post exp undefined use port fine color title timeout
export function saveEssay(essay){ $.ajax({ url: ‘http://127.0.0.1:1724/saveessay‘, type: ‘post‘, data:essay, dataType: ‘json‘, timeout: 1000, cache: false, success:function(data){ // resolve(data) }, error:function(){ // reject() } }) }
app.post(‘/saveessay‘, function(req, res){ console.log(req.body) })
req.body收到的是undefined
var bodyParser = require(‘body-parser‘);
app.use(bodyParser());
解析body中的内容
成功
pic20
{ title: ‘1‘, content: ‘‘, id: ‘2‘ }
pic 21
保存文章
pic22
数据库保存成功
标签:post exp undefined use port fine color title timeout
原文地址:http://www.cnblogs.com/heinz-lxy/p/6666419.html