Using success/error/finally/catch with Promises in AngularJS
Date : March 29 2020, 07:55 AM
wish of those help Promises are an abstraction over statements that allow us to express ourselves synchronously with asynchronous code. They represent a execution of a one time task. They also provide exception handling, just like normal code, you can return from a promise or you can throw. try{
try{
var res = $http.getSync("url");
res = someProcessingOf(res);
} catch (e) {
console.log("Got an error!",e);
throw e; // rethrow to not marked as handled
}
// do more stuff with res
} catch (e){
// handle errors in processing or in error.
}
$http.get("url").
then(someProcessingOf).
catch(function(e){
console.log("got an error in initial processing",e);
throw e; // rethrow to not marked as handled,
// in $q it's better to `return $q.reject(e)` here
}).then(function(res){
// do more stuff
}).catch(function(e){
// handle errors in processing or in error.
});
|
Why Success or Error callback function not executing properly for $http.post in angularjs
Date : March 29 2020, 07:55 AM
it fixes the issue My guess is you aren't binding $scope.Save() to ng-submit of
|
Error with $http.get in angularJS -- Success not a Function
Date : March 29 2020, 07:55 AM
this will help The .success and .error methods are deprecated and have been removed from AngularJS 1.6. Use the standard .then method instead. $http.get('https://api.github.com/users')
.then(function (response) {
var data = response.data;
var status = response.status;
var statusText = response.statusText;
var headers = response.headers;
var config = response.config;
$scope.user = data;
console.log(data);
});
|
AngularJS $http success function not working
Date : March 29 2020, 07:55 AM
|
How to use success and error in Angularjs if not using $http?
Date : March 29 2020, 07:55 AM
|