{"id":18005335,"url":"https://github.com/suissa/angular-chain-http-promises","last_synced_at":"2025-04-04T10:37:36.343Z","repository":{"id":140332612,"uuid":"69422215","full_name":"suissa/angular-chain-http-promises","owner":"suissa","description":"Example how chain promises with Angular´s $http ","archived":false,"fork":false,"pushed_at":"2017-03-02T15:37:01.000Z","size":6,"stargazers_count":2,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-09T20:44:15.597Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suissa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-09-28T03:32:21.000Z","updated_at":"2017-03-02T15:37:02.000Z","dependencies_parsed_at":null,"dependency_job_id":"3924ae1d-c05b-4b77-b150-962b2461f8b9","html_url":"https://github.com/suissa/angular-chain-http-promises","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suissa%2Fangular-chain-http-promises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suissa%2Fangular-chain-http-promises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suissa%2Fangular-chain-http-promises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suissa%2Fangular-chain-http-promises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suissa","download_url":"https://codeload.github.com/suissa/angular-chain-http-promises/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247164401,"owners_count":20894636,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T00:19:07.133Z","updated_at":"2025-04-04T10:37:36.308Z","avatar_url":"https://github.com/suissa.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# angular-chain-http-promises\n\nExample how chain promises with Angular´s $http.\n\n\n```js\nangular.module('myApp', [])\n.service('CEPService', CEPService)\n.controller('MainCtrl', MainCtrl);\n\nfunction MainCtrl ($scope, $http, CEPService) {\n\n/**\nMostrando as 2 formas onde cada resposta é enviada diretamente ao $scope\ne usando um Array externo que é populado a cada promise\ne na depois de todas ocorrerem uso o finally para jogar o Array p/ o $scope\ne pegando os erros com catch\n*/\n\n  const enderecos = []\n  $scope.error = false\n  CEPService.find('06608430')\n  .then((json) =\u003e {\n    $scope.part1 = json.data; \n    enderecos.push(json.data);\n    return CEPService.find('80610905');\n  })\n  .then((json) =\u003e {\n    $scope.part2 = json.data; \n    enderecos.push(json.data);\n    return CEPService.find('80510170');\n  })\n  .then((json) =\u003e {\n    $scope.part3 = json.data; \n    enderecos.push(json.data);\n  })\n  .catch(function(err) {\n    $scope.errorMessage = 'Deu merda: ' + err.toString();\n    $scope.error = true\n  })\n}\nMainCtrl['$inject'] = ['$scope', '$http', 'CEPService']\n\nfunction CEPService ($http) {\n  const BASE_URL = 'http://labs.edysegura.com/busca-por-cep/cep/endereco.php?cep='\n  \n  this.find = function (cep) {\n    return $http.get(BASE_URL + cep)\n  }\n}\nCEPService['$inject'] = ['$http']\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuissa%2Fangular-chain-http-promises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuissa%2Fangular-chain-http-promises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuissa%2Fangular-chain-http-promises/lists"}