I20160428-20:30:52.505(3)? Exception from sub battles id ZYdctF5sKwL4ueJaw TypeError: Cannot read property 'username' of undefin
ed
I20160428-20:30:52.506(3)? at [object object].Accounts.onCreateUser.user.profile [as _handler] (server/Publish.js:35:1)
I20160428-20:30:52.506(3)? at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20160428-20:30:52.506(3)? at [object object]._.extend._runHandler (livedata_server.js:1023:17)
I20160428-20:30:52.507(3)? at [object object]._.extend._startSubscription (livedata_server.js:842:9)
I20160428-20:30:52.507(3)? at [object object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
I20160428-20:30:52.507(3)? at livedata_server.js:548:43
I20160428-20:30:52.630(3)? Exception from sub battles id cNsHcdHbyTY2jqJLr TypeError: Cannot read property 'username' of undefin
ed
I20160428-20:30:52.630(3)? at [object object].Accounts.onCreateUser.user.profile [as _handler] (server/Publish.js:35:1)
I20160428-20:30:52.630(3)? at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20160428-20:30:52.631(3)? at [object object]._.extend._runHandler (livedata_server.js:1023:17)
I20160428-20:30:52.631(3)? at [object object]._.extend._startSubscription (livedata_server.js:842:9)
I20160428-20:30:52.631(3)? at [object object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
I20160428-20:30:52.631(3)? at livedata_server.js:548:43
Meteor.publish('battles', function()
{
var x = Meteor.users.findOne({_id: this.userId});
return battles.find({$or: [{name1: x.username}, {name2: x.username}]}, {
fields: {
name1 : 1,
name2 : 1,
battleID: 1,
BS : 1
}
});
});
The problem is eliminated if the user Selaginella, but if he goes out, home again is displayed only partially
this.userId
is empty and the query Meteor.users.findOne
returns nothing. And then you data from that anything trying to use fields to refer to. This is what you need to check:if (!currentUser) {
return [];
}
Find more questions by tags JavaScriptMeteor