Dan*_*aze 5 javascript node.js meteor iron-router
我试图将POST数据传递到外部流星的铁路由器路由,但它不起作用.请求正文为空.
我已经尝试输出请求体来检查数据是否存在,但它只是空的.
Router.route('/api/gatewaysusers', function() {
body = this.request.body;
console.log(this.request)
// this.response.write(body);
this.response.end("Call served");
}, {where: 'server'})
Run Code Online (Sandbox Code Playgroud)
任何的想法 ?谢谢.
它request.body是空的,因为iron-router缺少负责提取url编码数据的中间件.这是一个BUG,希望在以后的版本中解决.现在你可以添加:
Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
extended: false
}));
Run Code Online (Sandbox Code Playgroud)
在您的服务器上的某个地方它应该工作正常.看这里了解更多详情.
| 归档时间: |
|
| 查看次数: |
3958 次 |
| 最近记录: |