Newb Question About Meteor.methods

if (Meteor.isServer) {
Meteor.methods({
testRequest: function () {
this.unblock();
return Meteor.http.call(“GET”, “http://www.google.com”);
},
testKnex: function () {
// this.unblock();
// var result = knexWorker();
// knexWorker();

      return knexWorker(function(val){
        //val is result
        console.log("result -> (val)", val);
        return val;
      });



    }
});

}

function knexWorker(cb){

var knex = require(‘knex’)({
client: ‘pg’,
connection: ‘postgresql://localhost/angularPizza’
});

knex(‘users’)
.select(’*’)
.then(function(result){
console.log("result from knex test: ", result[0]);
// return result[0];
cb(result[0])
})
.catch(function(error){
console.log("error with knex test: ", error);
// return error;
cb(error);
})
}

//The above is the server and below is the client if (Meteor.isClient) {
Meteor.call(“testKnex”, function(error, results) {
// var testTimeout = setTimeout(function(){
// console.log(error);
// console.log(results.);
// },10000);
//returns undefined
// On the client, if you do not pass a callback and you are not inside a stub, call will return undefined, and you will have no way to get the return value of the method. That is because the client doesn’t have fibers, so there is not actually any way it can block on the remote execution of a method.
console.log(error);
console.log(results); //results.data should be a JSON object

    });
}

if (Meteor.isClient) {
    Meteor.call("testRequest", function(error, results) {
        // console.log(results.content); //results.data should be a JSON object
        console.log("results: ", results);
    });
}

}

So testKnex works to the extent that it gets the data to the server. I confirm this with a console log. But the client always saysa undefined. The testRequest works perfect, the data gets sent to the client. I don’t know how to fix the testKnex to make it work. I am brand new to Meteor. I know I should take advantage of Mongo and the built in power but let’s say that I wanted to get the data from the server to the client in the testKnex method, how would I do that?

Thank you for reading.

I figure it out. I cannot find a delete button for my post. Best