Loading js/script.js +22 −0 Original line number Diff line number Diff line const barreRechercheCodePostal = document.getElementById("codePostalInput"); const boutonRechercheCodePostal = document.getElementById("recherche"); let villes = []; boutonRechercheCodePostal.addEventListener("click", onRechercher); function onRechercher(){ Loading @@ -23,3 +25,23 @@ function onRechercher(){ function onErreurDeSaisie(message){ alert(message); } const setVilles = async codepostal => { return fetch("https://geo.api.gouv.fr/communes?codePostal="+codepostal) .then(res =>{ if(!res.ok){ throw new Error("gofuckyourself") } return res.json(); }) .then(data =>{ villes = []; for(i = 0; i < data.length; i++){ villes[i] = data[i].nom; } }) } const getVilles = () => { return villes; } No newline at end of file Loading
js/script.js +22 −0 Original line number Diff line number Diff line const barreRechercheCodePostal = document.getElementById("codePostalInput"); const boutonRechercheCodePostal = document.getElementById("recherche"); let villes = []; boutonRechercheCodePostal.addEventListener("click", onRechercher); function onRechercher(){ Loading @@ -23,3 +25,23 @@ function onRechercher(){ function onErreurDeSaisie(message){ alert(message); } const setVilles = async codepostal => { return fetch("https://geo.api.gouv.fr/communes?codePostal="+codepostal) .then(res =>{ if(!res.ok){ throw new Error("gofuckyourself") } return res.json(); }) .then(data =>{ villes = []; for(i = 0; i < data.length; i++){ villes[i] = data[i].nom; } }) } const getVilles = () => { return villes; } No newline at end of file