angularjs - How to continue promise chain after retry? -
i'm using restangular make multiple calls backend, have dependency on result of first call execute subsequent calls.
i'm trying setup retry logic follow on requests executed after retry succeeds. here's code far:
reefservice.creategitlabproject(formdata) .then(function(apiresponse) { $scope.apistatus.messages.push({'direction': 'in', 'body': apiresponse.result}); $scope.progressvalue += 1; var gitlabproject = { 'id': apiresponse.data.id, 'http_url_to_repo': apiresponse.data.http_url_to_repo, 'ssh_url_to_repo': apiresponse.data.ssh_url_to_repo }; // add deploy key reefservice.addgitlabdeploykey(gitlabproject) .then(function(apiresponse) { $scope.apistatus.messages.push({'direction': 'in', 'body': apiresponse.result}); $scope.progressvalue += 1; }) .catch(function(apierror) { $scope.apistatus.errors.push(apierror); }); // add web hook reefservice.addgitlabprojecthook(gitlabproject) .then(function(apiresponse) { $scope.apistatus.messages.push({'direction': 'in', 'body': apiresponse.result}); $scope.progressvalue += 1; }) .catch(function(apierror) { $scope.apistatus.errors.push(apierror); }); // failed create project }) .catch(function(apierror) { $scope.apistatus.errors.push(apierror); }); retry called manually, passed apierror restangular object $scope.apistatus.errors. i'm using following:
$scope.retryrequest = function(error){ var restangularconf = error.config; $http(restangularconf) .then(function(apiresponse) { $scope.progressvalue += 1; // add response messages $scope.apistatus.messages.push({'direction': 'in', 'body': apiresponse.data.result}); // delete error errors array var ix = $scope.apistatus.errors.indexof(error); $scope.apistatus.errors.splice(ix, 1); }) .catch(function(apierror) { toaster.pop('error', 'retry error', apierror.data.message); }); }; it receives apierror , runs $http call using data in apierror.config (url, post data etc.). works fine calls no dependencies addgitlabdeploykey , addgitlabprojecthook, i'm having trouble working out how setup creategitlabproject after error passed $scope.retryrequest , request completes, addgitlabdeploykey , addgitlabprojecthook continue.
how can setup $q service in creategitlabproject request chain continues after retry?
thanks help!
it appears i'm missing point of promises, i'd need wrap in function , pass function retry array , retry way...
Comments
Post a Comment