【问题标题】:Meteor unable to access callback response paramMeteor 无法访问回调响应参数
【发布时间】:2016-08-07 06:23:00
【问题描述】:

带有 mdg:validated-method 的 Meteor 1.3

imports/api/user/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;
    }
});

imports/ui/pages/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();
    }
});

我无法在UserMethods.register.call({mobile}, (error, response) 中访问response

如何解决这个问题?

【问题讨论】:

    标签: meteor meteor-helper


    【解决方案1】:

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

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

    回调响应本质上来自服务器。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-05-28
      • 2016-01-04
      • 2023-03-04
      • 1970-01-01
      • 1970-01-01
      • 2016-04-05
      • 2021-11-11
      • 1970-01-01
      相关资源
      最近更新 更多