From 5e5834ee3924c4f517daa8ef04354ba19a37064d Mon Sep 17 00:00:00 2001 From: CANCI0 Date: Mon, 8 Apr 2024 00:01:32 +0200 Subject: [PATCH] =?UTF-8?q?Menos=20c=C3=B3digo=20duplicado?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- webapp/src/pages/Bateria/Bateria.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/webapp/src/pages/Bateria/Bateria.js b/webapp/src/pages/Bateria/Bateria.js index f6d1bdf5..d8dadaca 100644 --- a/webapp/src/pages/Bateria/Bateria.js +++ b/webapp/src/pages/Bateria/Bateria.js @@ -88,19 +88,19 @@ const JuegoPreguntas = () => { avgTime: tiempoMedio, }, }; + + saveGame("/saveGame"); + saveGame("/saveGameList"); + }; + + const saveGame = async (endpoint) => { try { - const response = await axios.post(URL + '/saveGame', newGame); + const response = await axios.post(URL + endpoint, newGame); console.log("Solicitud exitosa:", response.data); } catch (error) { console.error('Error al guardar el juego:', error); } - try { - const response = await axios.post(URL + "/saveGameList", newGame); - console.log("Solicitud exitosa:", response.data); - } catch (error) { - console.error("Error al guardar el juego:", error); - } - }; + } const handleSiguientePregunta = async (respuesta) => { if (respuesta === preguntaActual.correcta) {