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)
如何解决这个问题?
答案 0 :(得分:0)
因此对于遇到同样问题的人来说,问题是我没有在服务器上加载imports/api/user/methods.js
!
/app/imports/startup/server/api.js
import '../../api/user/methods';
回调响应主要来自服务器。