A
A
Alecxandrys2015-11-09 16:42:48
MongoDB
Alecxandrys, 2015-11-09 16:42:48

Why is an exception thrown when calling a method?

Good afternoon
The following method adds additional information for the user to the database upon registration

Accounts.onCreateUser(function(options, user) {
    if(!options || !user) {
        console.log('error creating user');
        return;
    } else {
        if(options.profile) {user.profile = options.profile;}
        user.rateELO=100;
        user.rateCombine=1;
        user.battleCount=0;
        user.winPercent=0.00;
    }
    return user;
});

After adding it, the Meteor server began to throw out an action with the following content
I20151109-14:51:36.022(3)? Exception from sub battles id 7L2jjjuZyai6Ko9h9 TypeError: Object [object Object] has no method 'user'
I20151109-14:51:36.023(3)?     at [object Object].Accounts.onCreateUser.user.profile [as _handler] (server/Publish.js:25:1)
I20151109-14:51:36.023(3)?     at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20151109-14:51:36.024(3)?     at [object Object]._.extend._runHandler (livedata_server.js:1023:17)
I20151109-14:51:36.024(3)?     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
I20151109-14:51:36.024(3)?     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
I20151109-14:51:36.024(3)?     at livedata_server.js:548:43
I20151109-14:53:36.411(3)? Exception from sub battles id urKhdT94eF75a4ssC TypeError: Object [object Object] has no method 'user'
I20151109-14:53:36.411(3)?     at [object Object].Accounts.onCreateUser.user.profile [as _handler] (server/Publish.js:25:1)
I20151109-14:53:36.411(3)?     at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20151109-14:53:36.412(3)?     at [object Object]._.extend._runHandler (livedata_server.js:1023:17)
I20151109-14:53:36.412(3)?     at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
I20151109-14:53:36.412(3)?     at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
I20151109-14:53:36.412(3)?     at livedata_server.js:548:43

The method is used 1 time. As I can understand, the method is referenced in the description of the exception.
What is the error and how to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2015-11-09
@Alecxandrys

In your previous question, in the publication you have a piece of code:
this.user () - there is no such method, so it swears

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question