I'm migrating a project to Sails.js, I decided use Sails because I need to chaing many functions to single path and in it's documentation sais it is posible but I tryed a single example and I can not make it works, when I try to execute two functions on a path i got this error:
Error:
next(as in req,res,next) should never be called in an action function (but in actionalgo/fn1, it was!) It was called with no arguments. Please use a method likeres.ok()orres.json()instead.
What am I doing wrong or how can I make it works? this is my code:
routes.js
// ...
'get /chain': [
'AlgoController.fn1',
'AlgoController.fn2'
],
// ...
AlgoController.js
let Controller = {};
Controller.fn1 = function(req, res, next) {
req.executed = ['executed fn1'];
next();
};
Controller.fn2 = function(req, res, next) {
req.executed.push('executed fn2');
res.send(req.executed.join(' and '));
};
module.exports = Controller;
If I delete the next() or use res.ok() / res.json(), the second function is never executed.