Please see the demo here
function get(url) {
return $http.get(url)
.then(function(d){
return d.data
},
function(err){ //will work without handling error here, but I need to do some processing here
//call gets here
//do some processing
return err
})
}
get('http://ip.jsontest.co')
.then(function(response){
$scope.response = "SUCCESS --" + JSON.stringify(response);
}, function(err){
$scope.response = "ERROR -- " + err;
})
I have a library function, get
, which returns a promise. I am processing the error there, and returns it (where I commented //do some processing
). I was expecting in the client, it calls the error/fail handler. instead it prints "SUCCESS --" + error
I can make this work with $q
and reject
, but is there a way without?