node.js - Beforeremote for all api calls loopback -


is possible write common beforeremote hook api calls in loopback. able write beforeremote hook api's in particular model through models object like:

modelobj.beforeremote('*', function (ctx, req, next) {     //code     next() }); 

likewise possible write 1 before remote api calls. appreciated! thankyou!

i got answer , posting here use in same situation. in boot script file, use following code:

module.exports = function(app) {   var remotes = app.remotes();   remotes.before('**', function (ctx, next) {     //code execute before api calls goes here     next();   }); }; 

thats it!!!!


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -