The preferred way of getting a result from a async meteor call to the client

I’m fiddling around with promises, await, wrapasync etc and finding it very difficult to know what MDG actually aim for here, what they want us to use next year.

I think it is a fairly common problem and it should have a fairly straightforward solution, but I find more questions than answers when I dig into this.

I have been using my own solution with a mongo collection as transporter, but I know it’s not the future. What is?

This is how I do it. @robfallows sorry you asked about this a while ago.

Method on the server:

  async getInvoicePDF() {
    function invoicePromise() {
      return new Promise( (resolve, reject) => {
        chargebee.invoice.pdf('DemoInv_104').request(
          (error,result) => {
            if(error){
              console.log(error);
            } else{
              resolve(result.download.download_url);
            }
          }
        );
      });
    }

    let invoice = invoicePromise();
    return invoice;
  },

Method on the client (Polymer):

    getInvoicePDF: function() {
      (async function() {
        await Meteor.call('getInvoicePDF', (err,res) => { console.log(res) });
      }());
    },

“Polymer”?

random chars to get to min length lkjh kjhslfdkgjh ökjadfhg

  (async function() {
    await Meteor.call('getInvoicePDF', (err,res) => { console.log(res) });
  }());

This is what you need to care about.

It’s just wrapped inside a method call of a Polymer component. Ignore the outer wrapper getInvoicePdf: function()