8
我有一個鐵路由器路由,我希望通過HTTP POST請求接收緯度/經度數據。如何從流星訪問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
不包含發佈信息嗎?我試圖檢查對象和請求,但我找不到它。
** ** request.body就是我一直在尋找.. 謝謝! – gozzilli