Possibly unhandled rejection in Angular 1.6

前端 未结 9 1568
轻奢々
轻奢々 2020-12-06 04:31

I have a code with AngularJS:

service.doSomething()
  .then(function(result) {
      //do something with the result
  });

In AngularJS 1.5.

9条回答
  •  臣服心动
    2020-12-06 04:40

    I have solved this error by adding a default value in the catch block like:

    service.doSomething()
        .then(function(response) {
            var x = null;
            var y = x.y;
        }).catch(function(error) {
            var y = 0;
        });
    

    (take in count that I am not an experienced angular developer)

提交回复
热议问题