someMethod = new ValidatedMethod({
name: 'someMethodName',
validate: new SimpleSchema({
subId: {type: String, min:1},
planId: {type: String}
}).validator(),
async run(params){
try{
//params is undefined
}
}
});
Using async run(params)
causes params
to be undefined (seems like the context switches to Global
context). Removing the async
works fine. Why is this, and how can I still use await
inside a ValidatedMethod
?
Note1 : I get the same result if I try to use a regular Meteor.methods({}) definition. I am calling the method using Meteor.apply from the client
Meteor.apply(methodName, methodArgs, {wait:true}, function(error, result){...});
Note 2: I have also traced it through to the internals of Meteor.apply , where it is in fact sending the paramsObject
over DDP, in debug session:
// Sends the DDP stringification of the given message object
_send(obj) {
this._stream.send(DDPCommon.stringifyDDP(obj));
}
Many thanks for any insight.