From 2dddbbae6b1efb3a3690988051537ea588f11b1b Mon Sep 17 00:00:00 2001 From: jx163 Date: Sat, 9 Aug 2025 15:11:46 +1200 Subject: [PATCH] Updated to allow WeatherAPI support by adjusting request params and parsing. --- src/components/Widgets/WeatherForecast.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/Widgets/WeatherForecast.vue b/src/components/Widgets/WeatherForecast.vue index c95c045d..1f62ae3b 100644 --- a/src/components/Widgets/WeatherForecast.vue +++ b/src/components/Widgets/WeatherForecast.vue @@ -57,7 +57,8 @@ export default { }, endpoint() { const { apiKey, city } = this.options; - const params = `?q=${city}&cnt=${this.numDays}&units=${this.units}&appid=${apiKey}`; + const count = this.numDays * 8; + const params = `?q=${city}&cnt=${count}&units=${this.units}&appid=${apiKey}`; return `${widgetApiEndpoints.weatherForecast}${params}`; }, tempDisplayUnits() { @@ -92,9 +93,12 @@ export default { /* Process the results from the Axios request */ processData(dataList) { const uiWeatherData = []; - dataList.list.forEach((day, index) => { + + const step = 8; + for (let i = 1; i < dataList.list.length; i += step) { + const day = dataList.list[i]; uiWeatherData.push({ - index, + index: i, date: this.dateFromStamp(day.dt), icon: day.weather[0].icon, main: day.weather[0].main, @@ -102,7 +106,7 @@ export default { temp: this.processTemp(day.main.temp), info: this.makeWeatherData(day), }); - }); + } this.weatherData = uiWeatherData; }, /* Process additional data, needed when user clicks a given day */