I'm new to FeathersJS and want to add additional data to the user object after authorization. (I want to access the data with app.get('user').newData
)
First I tried to set a value in hook.result.newData
, but it doesn't work. I'm only able to change an existing value like email.
module.exports = function(options) {
return function(hook) {
hook.result.households = hook.app.service('households').find({'people.userId': hook.id}).then(household => {
console.log('households: ', household.data);
return household.data;
});
hook.result.email = '!' + hook.result.email + '?'; // this works
hook.result.newData = 'test'; // this doesn't work
};
};
Another approach I tried was modifying the code snippet found here: https://github.com/feathersjs/feathers-hooks/issues/56 but also with no success.
But I'm also not sure how to populate in my case. I want to add objects of another service, which have an array of user ids. And I only want those objects, which contain the own user id among others in the array.