我在 Web 应用程序中使用 Meteor 和 angularJS 2。请看下面的发布功能。
Meteor.publish('abc', function () {
// For throwing the meteor error according to the condition
if(!this.userId) throw new Meteor.Error(403,'UnAuthorized error');
// Returning the collection.
return collection.find();
});
现在,在从 angularjs2 订阅上述出版物时,我使用以下代码:-
//变量声明
this.meteorSubscription = MeteorObservable.subscribe("abc").subscribe(() => {
// Here subscribe data ready, so I called to other method.
});
问题在于,我如何捕获发布函数错误
'throw new Meteor.Error(403,'UnAuthorized error')'
最佳答案
subscribe方法的第二个参数是错误回调,所以你可以在这里写一些条件。
this.meteorSubscription = MeteorObservable.subscribe("abc").subscribe(() =>{
// Here subscribe data ready, so I called to other method.
},error => console.log('error',error));
关于javascript - Meteor发布错误检测,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42850420/