我尝试调用meteTor方法,但它使我失误了" typeError:meteor.call.call不是一个函数",但是当我尝试在imports/api/api/api/api/ex的另一个文件中调用同一函数时有些。这有效,这意味着呼叫代码是正确的,但是它在OnSubmit内部起作用,为什么?这是github url
文件: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
}
});
确保您正确导入流星:
import { Meteor } from 'meteor/meteor'