所以,这个问题已经被很好地记录在案,但我在这里,再次卡住了......
在服务器端,我已经发布:
Meteor.publish('userData', function(){ if (!this.userId) { return null; }
return Meteor.users.find({}, {fields: {'profile': 1}}); });
在客户端路由器订阅中,我有:
this.register('userData', Meteor.subscribe('userData'));
然后在我的客户端代码中,我有:
if (Meteor.userId()) {
var profile = Meteor.users.find(Meteor.userId()).profile;
console.log(profile); // I keep getting undefined...
我没有使用自动发布或不安全的包。
我在 mongodb 集合中的数据如下所示:
{"_id" : "...", profile: { "password" : { "network" : "...", "picture" : "none" } }
我的错误说:
Uncaught TypeError: Cannot read property 'password' of undefined
想法?