I'm trying to return the stdout of my method but on the client I always have undefined despite the server says it's a string with content.

I do that:

'getExistingFiles': function () { var list = ""; return new Promise(Meteor.bindEnvironment(function(resolve) { child = exec_tool("ls -al", function (error, stdout, stderr) { if (error !== null) { console.error('exec error: ' + error); list = "error: " + error; resolve(list); return list; }else{ list = stdout; console.log(typeof list); console.log("LIST:------------"); console.log(list); resolve(list); return list; } }); })); }

On my terminal I have the logs:

But on the client when I try to access the value it's undefined :

Meteor.call("getExistingFiles",function(list){ console.log(list); console.log(typeof list); });

So my question is, how could I send this list to the client ?

[EDIT] I tried like this to test if it was my client who was wrong but no it's on the server I think

//server var et = Meteor.wrapAsync(exec_tool); try { child = et('ls -al'); console.log("LIST:------------"); console.log(child); console.log(typeof child); return child; } catch (err) { throw new Meteor.Error(err, err.stack); }

[EDIT2] even like this it send a undefined WHY ?!