Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created June 3, 2019 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/39cd8ccde05ab468bb8d14cee886d118 to your computer and use it in GitHub Desktop.
Save parzibyte/39cd8ccde05ab468bb8d14cee886d118 to your computer and use it in GitHub Desktop.
const $btnPeticion = document.querySelector("#btnPeticion"),
$resultados = document.querySelector("#resultados");
$btnPeticion.addEventListener("click", () => {
$resultados.textContent = "Cargando...";
fetch("https://httpbin.org/")
.then(resultadoRaw => {
// Lo decodificamos como texto plano
return resultadoRaw.text();
})
.then(resultadoComoTexto => {
$resultados.textContent = resultadoComoTexto;
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment