Jessie Emerson Jessie Emerson - 1 year ago 63
Javascript Question

passing param to a method exposed from another controller

I want to pass params to method declared in controller B, says it's conB.js and look like this

module.exports.verify = function(req,res,next){
// how to get it here?

Then now I'm have conA.js, how can I pass arguments to it?

I know firstly I have to include it,

var ConB = require('ConB');

but how to pass param to verify method like ConB.verify('param') so that I can get it in ConA.js?

Answer Source

Not sure I undestand what you are trying to do but if you want to call verify with a parameter you have to define as a function accepting the parameter. So conB.js is:

module.exports.verify = function(param){
   // do something with param
   return something;

Then in conA.js:

var conB = require('./conB.js');
var result = conB.verify(your_param);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download