Possibly unhandled rejection: {}

后端 未结 1 1132
孤街浪徒
孤街浪徒 2021-01-21 13:17

\"Please

I got the error:

Possibly unhandled rejection: {}

相关标签:
1条回答
  • 2021-01-21 13:59

    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()'
    0 讨论(0)
提交回复
热议问题