Hi .
I want to create a profile page for all users. Where you can share users’ general information.
In the following code, I get the user username and try to share its general information:
const ProfileSection = withTracker(({ userName }) => {
const handle = (Meteor.isClient) ? Meteor.subscribe('Pages.Profile', userName) : { ready: () => true };
const loading = !handle.ready();
const data = Meteor.users.findOne({ username: userName }, {fields: {username:0 ,services:0,"profile.Type":0 ,"profile.PhoneNumber":0 }});
console.log(data);
return {
data,
loading
};
})(ProfileSectionn);
And I published the user information with the following code :
Meteor.publish('Pages.Profile', function (userName) {
const user = Meteor.users.findOne({ username: userName });
if (!user) {
throw new Meteor.Error('Not Found');
}
return Meteor.users.find({_id: user._id} , {limit:1,fields: {username:0 ,services:0,"profile.Type":0 ,"profile.PhoneNumber":0 }});
});
But the problem is, no data is shared, and this is the problem when a user is logged in.
I guess it 's because I’re getting two users, one is a logged in user, the other is a user I’m trying to subscribe to.
How do I solve the problem?