23 lines
878 B
JavaScript
23 lines
878 B
JavaScript
// Web de la votación. Esqueleto: muestra los resultados, pero votar aún no está hecho.
|
|
const API = window.API_URL;
|
|
|
|
async function cargarResultados() {
|
|
const caja = document.getElementById("resultados");
|
|
try {
|
|
const respuesta = await fetch(`${API}/api/resultados`);
|
|
const datos = await respuesta.json();
|
|
caja.textContent = JSON.stringify(datos);
|
|
} catch (error) {
|
|
caja.textContent = "No se pueden cargar los resultados (¿está la API en marcha? ¿CORS?)";
|
|
}
|
|
}
|
|
|
|
// TODO (equipo web): pintar las opciones de /api/opciones, enviar el voto con POST /api/votos
|
|
// y explicar al usuario cada respuesta del contrato (201, 400, 403, 409).
|
|
document.getElementById("formulario-voto").addEventListener("submit", (evento) => {
|
|
evento.preventDefault();
|
|
document.getElementById("mensaje").textContent = "Votar todavía no funciona.";
|
|
});
|
|
|
|
cargarResultados();
|