const formulario = document.getElementById("login-formulario"); const notificacion = document.getElementById("mensaje-error"); formulario.addEventListener("submit", async (event) => { event.preventDefault(); const numeroPersonal = document.getElementById("numero-personal").value; const contrasena = document.getElementById("contrasena").value; const data = new FormData(); data.append("numero-personal", numeroPersonal); data.append("contrasena", contrasena); try { const respuestaPeticion = await fetch('controladores/login.php', { method: "POST", body: data, }); <<<<<<< HEAD // const respuesta = await respuestaPeticion.json(); const respuesta = await respuestaPeticion.json(); if (respuesta.estado === 'exitoso') { window.location.href = 'views/inicio.html'; } else if(respuesta.estado === 'error') { notificacion.textContent = respuesta.mensaje; if(respuesta.res){ // Si existe respuesta.res hubo un error y se imprime en consola console.error(respuesta.res) } ======= const verificarCredenciales = await respuestaPeticion.json(); if (verificarCredenciales.loginExitoso) { window.location.href = 'inicio.html'; } else { notificacion.textContent = "Usuario y/o contraseña incorrectos"; >>>>>>> parent of a8e2895 (archivos de merge desde la rama recuperar-cambios) notificacion.style.display = "block"; } else { notificacion.textContent = "Lo sentimos, el servicio no está disponible por el momento"; console.error("No se recibió la respuesta esperada del servidor"); } } catch (error) { notificacion.textContent = "Lo sentimos, el servicio no está disponible por el momento"; } });