【发布时间】:2019-06-23 20:57:40
【问题描述】:
我尝试调用 metetor 方法,但它向我抛出错误“Uncaught TypeError: Meteor.call is not a function”,但是当我尝试在 imports/api/some.js 内的另一个文件中调用相同的方法时,这意味着调用代码是正确的,但它在 onSubmit 内部工作,为什么?这里是githuburl
文件:imports/ui/otp.js
onSubmit(e) {
e.preventDefault();
let otp = this.refs.otp.value.trim();
Meteor.call('find-otp', otp, (error, result) => {
if(error) {
console.log('otp error check', error);
} else {
console.log('otp res check', result);
}
});
}
文件:imports/api/db.js
Meteor.methods({
'find-otp' (otp) {
// if(!this.userId) {
// throw new Meteor.Error('not-authorized');
// }
console.log('otpcheck', otp);
return true;
// return otp; // also I try this
}
});
【问题讨论】:
-
你在导入
Meteor吗?即:import { Meteor } from 'meteor/meteor' -
thanx,我的愚蠢错误我忘记使用 {}。
标签: javascript reactjs meteor