用Iron Router从Ruby发布到流星?

问题描述 投票:0回答:1

我一直在尝试使用POST将消息从Ruby脚本发送到使用MeteorJS构建的webapp,但是我一直遇到一些问题。 在线上没有太多有关Iron Iron的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没有太多经验。 上面的代码我大多在线上获得。

铁路由器的路由:

 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或接收它。

谢谢!

ruby http post meteor iron-router
1个回答
0
投票

除了在服务器端路由中使用警报之外,我在Meteor端看不到任何问题。 可能希望将其更改为console.log,以查看出现什么错误。

© www.soinside.com 2019 - 2024. All rights reserved.