Meteor无法访问回调响应参数

时间:2016-04-15 10:17:58

标签: meteor meteor-helper

Meteor 1.3 with mdg:validated-method

进口/ API /用户/ methods.js

export const register = new ValidatedMethod({

    name: 'register',

    validate: new SimpleSchema({
        mobile: { type: String },
    }).validator(),

    run({ mobile }) {
        let response = {
            success: false,
            message: 'Error'
        };

        if(true) {
            response.success = true;
            response.message: 'Done';
        }

        return response;
    }
});

进口/ UI /页/ home.js

UserMethods.register.call({mobile}, (error, response) => {
    console.log(error); // okay
    console.log(response); // unable to access response

    if(response.success) {
        template.$('#enter-mobile').hide();
        template.$('#enter-otp').fadeIn();
    }
});

我无法访问response

中的UserMethods.register.call({mobile}, (error, response)

如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

因此对于遇到同样问题的人来说,问题是我没有在服务器上加载imports/api/user/methods.js

/app/imports/startup/server/api.js import '../../api/user/methods';

回调响应主要来自服务器。