Young Hong
Young Hong

Reputation: 37

Sails.JS pass data from the view to the controller

in Sails.js, I am trying to pass the role/mentor key/value pair to be received by the contoller function '/select'

VIEW.ejs

  ...
  $.post( '/select', {role: 'mentor'} );
  ...

CONTROLLER

select: function(req, res) {
    var printRole = req.param('role');
    return res.send("The role is: " + printRole); 
}

So far the result I receive on the screen is : The role is Undefined please help

Upvotes: 1

Views: 809

Answers (1)

Brad W
Brad W

Reputation: 2558

I think param should be plural as in var printRole = req.params('role')

Upvotes: 1

Related Questions