Skip to content

Commit

Permalink
chore: add files
Browse files Browse the repository at this point in the history
  • Loading branch information
eufelipe committed May 24, 2022
0 parents commit 51bdd4f
Show file tree
Hide file tree
Showing 4 changed files with 2,155 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
15 changes: 15 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "exercises-sync-async-cep",
"version": "1.0.0",
"description": "Exercício de criar um programa que retorna o endereço completo pelo cep - Estartando Devs ",
"main": "src/index.js",
"scripts": {
"test": "jest"
},
"keywords": [],
"author": "ED Team",
"license": "ISC",
"dependencies": {
"jest": "^28.1.0"
}
}
23 changes: 23 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
Para este exercício utilize o recurso de Async/Await do Javascript.
Será necessário buscar as informações em uma api externa (ViaCep).
Baixar o resultado, tratar o retorno.
Documentação da API: https://viacep.com.br/
*/

const BASE_API_VIA_CEP = "https://viacep.com.br/ws/";

function getCep(cep) {
return fetch(`${BASE_API_VIA_CEP}${cep}/json/`)
.then((response) => response.json())
.then((response) => {
if (response.erro) {
throw new Error(response.erro);
}
return response;
});
}
Loading

0 comments on commit 51bdd4f

Please sign in to comment.