I am very new to Meteor. I am doing simple app. Here is the problem I have:
Template.newFeedForm.events({
'submit #new-feed-form'(event) {
event.preventDefault();
const target = event.target;
const text = target.text;
Meteor.call('feeds.insert', text);
target.text.value = '';
}
});
So I have newFeedForm template and in my feeds.js I have
Meteor.methods({
'feeds.insert'(text){
check(text, String);
//check(hashtag, String);
// Make sure the user is logged in before inserting a task
if (! this.userId) {
throw new Meteor.Error('not-authorized');
}
console.log(this.userId);
// Feeds.insert({
// text: text,
// owner: this.userId,
// username: Meteor.users.findOne(this.userId).username,
// createdAt: new Date()
// });
}
});
I commented out the Feeds.insert here thinking that it causes the problem. Seems it is something different. Whenever Meteor.call is executed I got this:
Uncaught RangeError: Maximum call stack size exceeded
at Function._.(anonymous function) [as isArguments] (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:1068:30)
at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:512:25)
at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:530:5)
at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
at Object.EJSON.clone (http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:530:5)
at http://localhost:3000/packages/ejson.js?hash=0f17ced99d522d48cd8f8b2139167fd06babd969:531:22
at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:157:22)
Have no Idea what is happening. Here is my repo that reproduces this error: https://github.com/yerassyl/nurate-meteor
Typically, when errors like this occur (especially when dealing with a Meteor Method) it means you are probably not passing the "correct" data (or the data that you thought you were).
Looking at your form handling code, I noticed that you are never obtaining the textarea text data.
const text = target.text;
target.text returns the actual textarea DOM object but what you are really after is the value the object contains. The below code will solve your issue.
const text = target.text.value;