I have an Iron-router route with which I would like to receive lat/lng data through an HTTP POST request.
This is my attempt:
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));
}
});
});
But querying the server with:
curl --data "lat=12&lon=14" http://127.0.0.1:3000/receive
Returns {}
.
Maybe params
doesn't contain post data? I tried to inspect the object and the request but I can't find it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…