Possibly unhandled rejection: {}

£可爱£侵袭症+ 提交于 2020-01-15 09:38:11

问题


I got the error:

Possibly unhandled rejection: {}

I read the solution in this topic : Angular 1.6.0: "Possibly unhandled rejection" error

i tried But i dont know where i put fixed code, please kindly help me, thanks Thanks all !


回答1:


First option is simply to hide an error by disabling them with errorOnUnhandledRejections in $qProvider configuration:

app.config(['$qProvider', function ($qProvider) {
    $qProvider.errorOnUnhandledRejections(false);
}]);

BUT this will only switch off logging. The error itself will remain

The better solution in this case will be - handling a rejection with .catch() method:

service.doSomething()
 .then(function (response) {
   //normal processing
})
 .catch(function (err) {
     console.log(err);
     throw err;
});

Useful Links:

  • Promise
  • Migrating Angular 1.5 to 1.6
  • $http: remove deprecated callback methods: 'success()/error()'


来源:https://stackoverflow.com/questions/51831457/possibly-unhandled-rejection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!