Meteor : Retrieve value in Meteor.call which calls a server method having promise
<p>I have an internally maintained npm package <code>myNpmPackage</code> which exports a function (for e.g. <code>fnTestMicroSerConn</code> ) as below:</p>

<pre><code>const rp = require('request-promise-native')

exports.fnTestMicroSerConn = function () {
  return new Promise(function(resolve, reject) {
    var options = {
      method: 'GET',
      uri : "http://example.net", 
      resolveWithFullResponse: true,
    }
    rp(options)
      .then(function (response) {
        if (response.statusCode !== 200){
          console.error("http not 200 but : ",response.statusCode)
          resolve(false)
        } else  {
          console.info("connected successfully : "+response.body)
          resolve(response)
        }
      })
      .catch(function (err) {
          console.error("Error in establishing connectivity  : ",err)
          resolve(false)
      })
    })
}
</code></pre>

<p>I then need to call the above exported function from a Meteor method like so:</p>

<pre><code>import { Meteor } from 'meteor/meteor';
import myNpmPackage from 'myNpmPackage';

Meteor.methods({   
 foo: function () {
   myNpmPackage.fnTestMicroSerConn().then(function (response){
     console.log(" My response: ",response.body);
    return(response.body)
   })
 }
});
</code></pre>

<p><code>console.log(" My response: ",response.body);</code> gets executed successfully and I can see the expected value in <strong>the server console log</strong>. So till here it's good.</p>

<p>However, now I want to pass the value of <code>response.body</code> to the <strong>client side</strong>. In short, when I do below on the client :</p>

<pre><code>Meteor.call("foo", function (err, response) {
      console.log("calling foo");
      if(!err){
        console.log("response : ",response);
      } else {
        console.log("err : ",err);
      }
    })
</code></pre>

<p>Unfortunately, currently I am getting <code>undefined</code> on the client for <code>console.log("response : ",response);</code> </p>

<p>Note: I am using the Meteor Promise package from <a href="https://atmospherejs.com/meteor/promise" rel="nofollow">here</a></p>

<p>Let me know if any more details are needed or any thing is unclear. I am very new to the <em>Promise</em> style of coding, hence, this can sound as a noob question.</p>