Sudhanshu
Sudhanshu

Reputation: 457

Iron Router Meteor 1.2, this.request.body is empty

Meteor 1.2

Router.route('/upload', {
  where: 'server',
  action: function(){
    console.log(this.request.body);
    this.response.end(JSON.stringify(this.request.body));
  }
});

I am using the lines mentioned in earlier issues.

if (Meteor.isServer) {
    Router.onBeforeAction(Iron.Router.bodyParser.urlencoded({
        extended: false
    }));
}

Still the response is {}. Did this break with meteor 1.2? What is the solution now?

Upvotes: 0

Views: 338

Answers (1)

Miguel Muniz
Miguel Muniz

Reputation: 11

// this is my route

Router.map(function(){
    this.route('/posted',{where:'server'})
    .post(function(){
        console.log(this.request.body);
        this.response.end('post request\n');
    });
});

// this is my form

<form method="post" action="http://localhost:3000/posted">
    <input name="test" value="blah"></input>
    <input type="submit" value="Submit"></input>
</form>

// this is my reply on server's console

//I20151026-12:27:21.421(-6)? { test: 'blah' }

hope this helps

Upvotes: 1

Related Questions