Reputation: 131
I need a help in sails.js framework.i am developing the website in nodejs and sails.js framework. is there any way to call preload action in each controller.(for ex: the controller calling time load this action).each controller having different pre load action.
Please any one suggest to me.how can i create this way or any other way.
Thanks to all.
Upvotes: 0
Views: 187
Reputation: 3697
use a service:
/service/mypre.js:
exports.first = function(req,res,cb) {
// here add you code
cb();
}
in Controller:
module.exports = {
index: function(req,res) {
sails.mypre.first(req,res, function(){
// Do other things...
});
}
}
And you may add a callback to make sure, your mypre() is done completely.
Upvotes: 1