【问题标题】:POST from Ruby to Meteor with Iron Router?使用 Iron Router 从 Ruby 发布到 Meteor?
【发布时间】:2015-05-30 08:16:42
【问题描述】:

我一直在尝试使用 POST 从 Ruby 脚本向使用 MeteorJS 构建的 web 应用程序获取消息,但我遇到了一些问题。关于 Iron Router 的 POST 和 GET 方法管理的在线文档并不多。

我的 Ruby 脚本:

meteorUri = URI('http://localhost:3000/newReport');
res = Net::HTTP.post_form(meteorUri, 'message' => 'HelloFromRuby', 'max' => '50')
puts "From Meteor:\t#{res}"

我对 Ruby 没有太多经验。上面的代码我主要是在网上弄的。

Iron Router 的路由:

 Router.route('/newReport/:message', {where: 'server'})

    .post( function(message){

        Meteor.call('reportInsert', {message: message}, function(error, recordId){

            if (error){
                alert(error.reason);
            } else {
                console.log("Inserted " + recordId);
            }

        });
    });

我正在尝试让 Ruby 向 http://localhost:3000/newReport 发送一条消息,该消息应该是一个字符串。

reportInsert 函数有效,我测试过了。问题似乎在于发出 POST 或接收它。

谢谢!

【问题讨论】:

  • 还有什么问题?你有什么问题?
  • 消息没有通过。在 Meteor 端查看 MongoDB,发现没有收到消息。

标签: ruby http post meteor iron-router


【解决方案1】:

除了在服务器端路由中使用警报之外,我没有看到 Meteor 方面的任何问题。可能想将其更改为 console.log 以查看您遇到了什么错误。

【讨论】:

    猜你喜欢
    • 2013-11-23
    • 1970-01-01
    • 2017-06-17
    • 2015-01-21
    • 2016-10-31
    • 2014-06-01
    • 2014-05-07
    • 2013-11-21
    • 1970-01-01
    相关资源
    最近更新 更多