node.js - Remote hooks in loopback -


in loopback using afterremote hook request follows

modelname.afterremote("**", function(ctx, expenses, next){   if(ctx.method.name == 'find') {       for(var i=0; i<ctx.result.length; i++){         delete ctx.result[i].category;       }   } }); 

in above trying delete key request response before sending client. still appears. not possible delete key have created in model.json?. please share ideas. in advance.

you need use result.unsetattribute('field')

modelname.afterremote("**", function(ctx, expenses, next){   if(ctx.method.name == 'find') {     for(var = 0; < ctx.result.length; i++) {       ctx.result[i].unsetattribute('category');     }   } }); 

here related github issue, in case interested.

it documented in operation hooks section of loopback documentation, there sadly no mention of in remote hooks section.

note: if want restrict hook find method, can specify modelname.afterremote("find", function (ctx, expenses, next) {});.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo