javascript - Meteor.call is returning Error invoking Method 'addToMenu': Internal server error [500] -


I am new to the meteor and using Meteor.call () to push an object into the array in my collection I am trying to . This is my code.

My Template Event Map

  Click '.seave': Function (Event, Template) {var mealId = session.get ('selected'); Var range = template.find ("Category"). value; Var dish = template.fund ("dish"). value; If (category.length and dish.length) {addToMenu ({Category: Category, dish: dish});  

and my model in shared model. J.,

  addToMenu = function (options) {var id = Random.id (); Meteor.call ('addToMenu', _extension ({_id: id}, options)); Return id; }; Meteor.methods ({createMeal: function (options) {check, (date: string, time: string, alley: string, city: string, state: string, zipcode: string, _id: match, optional (string)} ); If (options.street.length> 100) throw new meteors error (413, 'street address is too long'); if (options.city.length> 25) throw new meteor error (error) 413, 'The city name is too long;) If (options.state.length> 20) throw a new meteor error (413,' State name is too long); if (! This.userId) throw new meteors Error (403, 'You must be logged in'); var id = options.id || Random.id (); Food.Instead ({_id: id, owner: this.userId, street: options.street, city : Options.city, status: options.state, zipcode: options.zipcode, date: options.date, time: options.time, menu: [], content: [], invite: [], rsvps: []}) ; Return id;}, addToMenu: function (option) {check (option, {class: string, dish: string, _id: matching optional (string)}; if (! This.userId) throw Ew Meteor.Error ( 403, "You must be logged in to add dishes."); If (! Food ID) throw new meteors Error (404, "no such food"); Food. Adoodt (food id, {$ addToSet: {menu: {category: options.category, dish: options.dish}}}}); },  

I just created a related archive that is called Menu and could set {owner: mealId}, but I really want to use embedded documents on MongoDB Any input would have been greatly appreciated.

I am guessing this problem that there is no mealId addToMenu < / Code> in the scope of the law variable. Maybe you want to pass it as a parameter:

  Meteor.methods ({addToMenu: function (mealId, option) {check (food id, string); // rest function body Unchanged}} ); AddToMenu = function (mealId, option) {var id = Random.id (); Meteor.call ('addToMenu', mealId, _.extend ({_id: id}, options)); Return id; }; 'Click. Save ': function (event, template) {var mealId = Session.get (' selected '); Var range = template.find ("Category"). value; Var dish = template.fund ("dish"). value; If (category.length & amp; amp; dish length) {addToMenu (mealId, {Category: Category, dish: dish}); }}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -