【发布时间】:2017-08-21 10:44:55
【问题描述】:
我正在尝试在 nodejs 中编写一个 post api 并使用 vuejs 作为前端框架并使用 vue-resource 来访问 apis 。这是我在前端的提交功能。
validateBeforeSubmit() {
var self = this;
this.$validator.validateAll().then(result => {
if (result) {
self.data = self.name;
console.log(this.data)
this.$http.post('/api/add_level',self.data).then(function(res){
this.status = res.body
console.log(this.status);
this.largeModal=false;
// eslint-disable-next-line
alert('From Submitted!');
})
return;
}
这是我在服务器端的代码。
app.post('/api/add_level',function(req,res,err,data){
console.log(data);
})
【问题讨论】: