Error in

I have this code in client

  'click .addcart': (event, template) ->
    add_this = {"item": 1, "name": "test", "qty": 5, "price": 124} "Carts.push", add_this

and in server

  'Carts.push': (params) ->
    console.log params

every time e click the botton add cart I got an error in server side

Exception while invoking method 'Carts.push' Error: Did not check() all arguments during call to 'Carts.push'

Any idea why this error persist?

I imagine it’s warning you to use the check() method to check that the parameters to the method are what you expected, such as a string or number or an object with the correct keys.


Exactly ^. Your Meteor.method needs a check for params, so…

   'Carts.push': (params) ->
      check params, Object // Add this
      console.log params

@jrudio @nkrisc Thanks! its now working

that is weird, I never run the check() function and haven’t seen that error.
The few methods I use only take certain inputs so I can explicitly check for those.

@cstrat I do not know if audit-argument-checks is a default package or not. If you do not want to check every params just remove audit-argument-checks package. See meteor doc about audit-argument-checks package

I don’t know if this code is from your real code, but it is really not secure. Just send the id of the item and then the server will fetch the full item from the DB. Otherwise the client can call the method and set the price to 0$.

It must not be a default package because like I said, never seen that error and I haven’t used check().

1 Like

@skini26 Yes your right. This is just for study proposes for now. No worries :smile: