[Solved] Method argument becomes undefined

Calling a fairly simple validated method called updateStatus:

requestId = this._id;
text = "some text";
updateStatus.call({ requestId, text });

The method looks roughly like this:

export const updateStatus = new ValidatedMethod({
name: 'updateStatus',
validate({requestId, newStatus}) {
},
    run({requestId, newStatus}) {
        // Verify if user is logged in
        console.log(requestId);
        console.log(newStatus);
    });

The first console.log properly logs the id of the request, whereas the 2nd one prints undefined.

Anyone knows what is going on?

in es6 { requestId, text} is equivalent to { requestId: requestId, text: text }
so newStatus isn’t a property of the objects passed to validate and run
you would have to write

export const updateStatus = new ValidatedMethod({
  name: 'updateStatus',
  validate({requestId, text}) {
  },
  run({requestId, text}) {
    // Verify if user is logged in
    console.log(requestId);
    console.log(text);
  }
);

or call your method this way

requestId = this._id;
text = "some text";
updateStatus.call({ requestId, newStatus: text });

Perfect, didn’t know I was using es6 all along, thanks a lot!