So I’ve just come up against the whole 'can’t callback client code from a Meteor.method
’ thing again. For example:
//on server
Meteor.methods({
'queryRemoteServer': function (connectionOpts, query) {
connection.connect(connectionOpts, function (err, conn) {
conn.query(query, function (err, data) {
return data //`data` is what I care about here.
}
}
}
)
// and now, on client
var data = Meteor.call({host: 'whatever.com'}, "SELECT *;");
//I want `data` here to be `data` up there!!
I think this comes up all the time, really. The sheer number of people with questions like this is proof enough.
The standard solutions include using Session
variables, abusing returnStubValue
, or using a promises package.
How come we don’t use ES6 Promises for Meteor.methods? And what exactly is the absolutely, 100% definitive solution for a case like this?
Cheers!