-
-
Save parzibyte/35e46b7a5edaa56abab9b0b18d315652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
En el clic del botón hacemos una petición a ./tomar_foto_guardar | |
*/ | |
const $btnTomarFotoServidor = document.querySelector("#btnTomarFotoServidor"), | |
$estado = document.querySelector("#estado"); | |
$btnTomarFotoServidor.onclick = async () => { | |
$estado.textContent = "Tomando foto..."; | |
const respuestaRaw = await fetch("./tomar_foto_guardar"); | |
const respuesta = await respuestaRaw.json(); | |
let mensaje = ""; | |
if (respuesta.ok) { | |
mensaje = `Foto guardada como ${respuesta.nombre_foto}`; | |
} else { | |
mensaje = `Error tomando foto`; | |
} | |
$estado.textContent = mensaje; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment