阅读Meteor.js中的POST内容

时间:2013-07-09 22:47:50

标签: javascript node.js post meteor

我想在我的Meteor应用程序中接收带有POST请求的数据。这个代码(服务器端):

__meteor_bootstrap__.app.stack.splice (0, 0, {
  route: '/input',
  handle: function(req, res, next) {

    req.on('error', function(err) {
      console.log('ERROR', err);
    });

    req.on('data', function(chunk) {
      console.log('CHUNK');
    });

    req.on('end', function() {
      console.log('END');
    });


    res.writeHead(200, {
      'Content-Type': 'text/plain',
    });
    res.write('GOT IT!');
    res.end();

  }.future(),

});

代码不起作用,永远不会调用带有日志的回调。我试图将响应代码移动到end回调,但它没有帮助 - 唯一的变化是请求收到超时而不是响应。

我该怎么办?

1 个答案:

答案 0 :(得分:1)

您的代码在没有future()电话的情况下适合我。

相关问题