【发布时间】:2015-12-20 12:41:14
【问题描述】:
我目前正在尝试从特定路由规则内的表单中捕获发布的值。 由于所有其他关于此的 SO 帖子都不起作用,我想再问一次。您是否在您的项目中对此进行了整理和实施? Iron-Router@1.0.9 有解决方案吗?
this.request.body
路由规则中的上述代码总是返回未定义的。
Router.route('/register', function(){
console.log( JSON.stringify(this.request.body) );
//this.render('test',{data:{data:this.request.body.username}})
});
//SERVER ONLY
if (Meteor.isServer) {
Meteor.methods({
'addSong': function(songName) {
var userId = Meteor.userId()
songs.insert({
userId: userId,
name: songName
})
}
})
Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
extended: true
}));
}
【问题讨论】:
-
我猜这是服务器端的,你能告诉我们一些代码吗?
标签: meteor iron-router body-parser