From c1f74c3db0cf245791ff85d02122c13453b9a930 Mon Sep 17 00:00:00 2001 From: Tatiana Villa Date: Sat, 21 Feb 2026 18:04:54 +0100 Subject: [PATCH] cambio de url para que filtre por ciudad y fechas --- eltiempo/index.html | 2 +- eltiempo/js/estadisticas.js | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/eltiempo/index.html b/eltiempo/index.html index f9bb81f..f066293 100644 --- a/eltiempo/index.html +++ b/eltiempo/index.html @@ -3,7 +3,7 @@ Estadísticas | El Tiempo - + diff --git a/eltiempo/js/estadisticas.js b/eltiempo/js/estadisticas.js index 439bc64..2eb1d98 100644 --- a/eltiempo/js/estadisticas.js +++ b/eltiempo/js/estadisticas.js @@ -10,7 +10,7 @@ let selectedMonth = new Date().getMonth(); // mes actual let ciudadActual = "Madrid"; // ciudad por defecto // Antes: const BASE_API = "https://aplicacionesdevanguardia.es/eltiempo/servidor/api-weather-fechas.php"; -const BASE_API = "https://tatvil.es/apis/api/weather/all"; +const BASE_API = "https://tatvil.es/apis/api/weather/filter"; // ==================== // Construir URL de API según filtros @@ -31,11 +31,16 @@ function buildApiUrl({ ciudad, fecha = null, desde = null, hasta = null }) { */ // AHORA: Como el nuevo backend Java devuelve TODO en /all, no podemos construir una URL con filtros. Por ahora, apuntamos directamente a /all y haremos el filtrado en el frontend. Esto es temporal hasta que implementemos los filtros en Java. -function buildApiUrl({ ciudad, fecha = null, desde = null, hasta = null }) { - // Por ahora, como tu Java devuelve todo en /all, apuntamos ahí - // El filtrado por ciudad lo haremos en el frontend hasta que lo programemos en Java - console.log("Cargando datos desde el nuevo Backend Java en tatvil.es"); - return BASE_API; +function buildApiUrl({ ciudad, desde, hasta }) { + const params = new URLSearchParams(); + params.append("ciudad", ciudad); + params.append("desde", desde); + params.append("hasta", hasta); + + console.log("Construyendo URL con parámetros:", { ciudad, desde, hasta }); + console.log("URL API:", `${BASE_API}?${params.toString()}`); + + return `${BASE_API}?${params.toString()}`; } // ====================