axios.post(this.props.submitUrl, {
Author: comment.author,
Text: comment.text,
Sex: comment.sex,
Hobby: comment.hobby,
__RequestVerificationToken: comment.veritoken
})
.then(function (response) {
var id = response.data;
comment.id = id as number;
var newComments = theThis.state.comments.concat([comment]);
theThis.setState({ comments: newComments });
})
.catch(function (error) {
console.log(error);
});
post 的第二个参数应该就是需要发送到server的data吧,server能接受这个post请求,但是就是数据拿不到。为何?
用chromer看看request header content-type 的值是什么? application/x-www-form-urlencoded 还是application/json,然后后台是用什么框架,express需要 bodyParser 中间件,koa需要koa-body中间件