问题
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