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


#1
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.


#2

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

#3

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