POST from Ruby to Meteor with Iron Router?

一曲冷凌霜 提交于 2020-01-06 19:27:41

问题


I've been trying to get a message from a Ruby script to a webapp built with MeteorJS using POST, but I've been facing some issues. There isn't much documentation online about POST and GET method management with Iron Router.

My Ruby script:

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

I don't have much experience with Ruby. The above code I got mostly online.

The routing with 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);
            }

        });
    });

I am trying to make Ruby make a post to http://localhost:3000/newReportwith a message that is supposed to be a string.

The function reportInsert works, I tested it. The issue seems to be in either making the POST, or receiving it.

Thank you!


回答1:


Beside using an alert in a server side route, I don't see any issues on Meteor's side. Might want to change it to console.log to see what error are you getting.



来源:https://stackoverflow.com/questions/30535969/post-from-ruby-to-meteor-with-iron-router

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!