So I have a form that on submit calls a method 'insertLesson' and it seems to work fine and console.log what I want it to console.log. But after the console.log statement it is giving me the error 'Error invoking Method 'insertLesson': Method 'insertLesson' not found [404]'
Here is my form handling:
Template.body.events({
'submit .lesson-plan'(e){
e.preventDefault();
let title = e.target.title.value;
let content = e.target.content.value;
Meteor.call('insertLesson',title,content);
}
});
Here is my insertLesson Method:
Meteor.methods({
insertLesson: function(title,content){
console.log(title);
console.log(content);
console.log('pre submitted')
}
});
and if I type "foo" in the title and "bar" in the content. My console will show:
foo bar Error invoking Method 'insertLesson': Method 'insertLesson' not found [404]
EDIT:
I hadn't realized I also had to import the the file where I declared a new Mongo.collection to my server side ... so in my server/main.js I now have the line:
import '../imports/api/lessons'
and everything is working
server/main.js must import the file where you declare the new mongo collection:
import '../imports/api/lessons'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.