I have a file that launch nodejs/restify server, when calls arrive to my server i do this:
apiserver.post('/:param',call1);
function call1(req, res, next) {
//treatment
}
But i want to place my functions in a script called functions.js, the problem is when i do this
var functions = require('./functions')
apiserver.post('/:param', functions.call1(req,res,next));
it say that req, res and next is undefiened variables.
The problem is that you're calling functions.call1
in your apiserver.post
call when what you want to do is pass the function itself as a parameter:
apiserver.post('/:param', functions.call1);