我有一个Iron-router路由,我想通过HTTP POST请求接收经纬度数据。
这是我的尝试:
Router.map(function () {
this.route('serverFile', {
path: '/receive/',
where: 'server',
action: function () {
var filename = this.params.filename;
resp = {'lat' : this.params.lat,
'lon' : this.params.lon};
this.response.writeHead(200, {'Content-Type': 'application/json; charset=utf-8'});
this.response.end(JSON.stringify(resp));
}
});
});
但是使用以下命令查询服务器:
curl --data "lat=12&lon=14" http://127.0.0.1:3000/receive
返回 {}
。
可能 params
没有包含POST数据?我尝试检查对象和请求,但是找不到它。