You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
The $http special promise methods success and error do not always chain as expected. These should work with the promise chain as expected and also be fully interoperable with the $q methods .then and .catch.
$http.get("https://cors-test.appspot.com/test").success(function (data) {
return $q(function (_, reject) { reject() });
}).error(function () {
console.log("first error should be logged, isn't");
});
$http.get("https://cors-test.appspot.com/test").success(function (data) {
return $http.get("http://doesnt.exist/")
}).success(function () {
console.log("second error is incorrectly considered a success");
}).catch(function () {
console.log("second error should be logged, isn't");
});
$http.get("https://cors-test.appspot.com/test").then(function (data) {
return $q(function (_, reject) { reject() });
}).catch(function () {
console.log("third error should be logged, is");
});
$http.get("https://cors-test.appspot.com/test").then(function (data) {
return $http.get("http://doesnt.exist/")
}).catch(function () {
console.log("fourth error should be logged, is");
});
This will emit
second error is incorrectly considered a success
third error should be logged, is
fourth error should be logged, is
The issue seems to be that if a promise is returned from the .success and .error callbacks, it is treated as a truthy value rather than continuing the promise chain. Instead, they should continue the promise chain.
The text was updated successfully, but these errors were encountered:
ajcrites
added a commit
to ajcrites/angular.js
that referenced
this issue
May 29, 2015
`.success` and `.error` methods will now continue the promise chain.
Returning a promise in either of these callbacks will be appropriately
handled by the chain.
Closesangular#11972
The
$http
special promise methodssuccess
anderror
do not always chain as expected. These should work with the promise chain as expected and also be fully interoperable with the$q
methods.then
and.catch
.http://plnkr.co/edit/csyUaNojCaUvN6k47V6C?p=preview
This will emit
The issue seems to be that if a promise is returned from the
.success
and.error
callbacks, it is treated as a truthy value rather than continuing the promise chain. Instead, they should continue the promise chain.The text was updated successfully, but these errors were encountered: