Using promises in meteor methods


#1

I am trying to use promises in methods. It works somehow, but in case of error, I have the annoyed "Uncaught (in promise) " error in the browser. What do I need to do to get rid of it?!

Thanks a lot in advance!

const a=0;
Meteor.call('f2', a, (err,res) => console.log(err,res) );

Meteor.methods({
    'f2'(a) {
        return new Promise( (resolve,reject) => {
            if(a)    resolve('f2 ok');
            else    reject(new Meteor.Error('f2','some error'));
        });
    },
});

#2

Use try/catch around your code if using async/await, else use .catch in your Promise chain.