3rd party npm module method returns a Promise. Recommendations?

import Foo from 'foo';

var res = Foo.bar(baz);
console.log(' returned ' + res );
console.log('.......................................');
console.log( res );

My server log shows :

returned [object Promise]
.......................................
 { _bitField: 0,
   _fulfillmentHandler0: undefined,
   _rejectionHandler0: undefined,
   _progressHandler0: undefined,
   _promise0: undefined,
   _receiver0: undefined,
   _settledValue: undefined,
   _trace: { [Error] _parent: undefined, _length: 1 } }

I’ve read How do I properly use an NPM module that returns a Promise? from Sept 2015, but a lot has changed since then.

Would someone please point me to the latest best practice example for getting a synchronous result from Foo.bar()?

Update : I’m using v1.3.3.

1 Like

Hah! Found it!

Meteor Guide : Using Packages >> Promises

Command line …

meteor add promise

server/methods.js …

var res = Promise.await(Foo.bar(baz));

server log …

 returned fubar
.......................................
fubar

Am I right that this will only work on the server, not in the client?