Possibly unhandled rejection: {}

2020-04-12 12:39发布

Please click here to see my issue

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条回答
手持菜刀,她持情操
2楼-- · 2020-04-12 13:03

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:

查看更多
登录 后发表回答