loopback
loopback copied to clipboard
Cannot access 'req' object in mixin
Hello,
I have a mixin that looks somewhat like this:-
Model.updateLog = function(ctx, next) {
console.log(ctx.req); //undefined
};
Model.observe('before save', function(ctx, next) {
Model.updateLog(ctx, next);
});
Is there any other way to access the 'req' object? I don't want to use the 'currentContext' feature available in loopback
Thanks
Hi @vasanthps-rm , you can try to use the remote hooks to get the req object
Model.updateLog = function(ctx, next) {
console.log(ctx.req);
next();
};
Model.beforeRemote('**', function(ctx, next) {
Model.updateLog(ctx, next);
});
Also please note that we would like to encourage users to post questions on our Google Forums as we only accept bug reports and feature requests through Github issues, closing this issue, please feel free to reopen.