Answer the question
In order to leave comments, you need to log in
How to resolve Exception in Meteor.js when opening main page?
Good afternoon,
When you open the main page, two exceptions fall out in the log and the page is not loaded to the end.
Log:
I20160428-20:30:52.505(3)? Exception from sub battles id ZYdctF5sKwL4ueJaw TypeError: Cannot read property 'username' of undefined
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 undefined
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
}
});
});
Answer the question
In order to leave comments, you need to log in
The problem is fixed if the user logs in, but if he logs out, the main page is only partially displayed again
this.userId
empty and the request Meteor.users.findOne
returns nothing. And then you try to use the data from this nothing , access its fields. This is exactly what you need to check:if (!currentUser) {
return [];
}
Spali WC Lite plugin can work with fields https://wordpress.org/plugins/saphali-woocommerce-lite/
or you can use https://wordpress.org/plugins/woocommerce-poor-guy...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question