From 5bb84dcefbafab8d80313771854c1d982560ee1a Mon Sep 17 00:00:00 2001 From: Bastien Wirtz Date: Sun, 30 Oct 2022 14:48:45 +0100 Subject: Fix openweather service --- src/components/services/OpenWeather.vue | 16 +++++++++------- src/components/services/Ping.vue | 7 +++++-- 2 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/components/services') diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue index 3169866..649e8e5 100644 --- a/src/components/services/OpenWeather.vue +++ b/src/components/services/OpenWeather.vue @@ -23,7 +23,7 @@

{{ name }}

- {{ temp | tempSuffix(this.item.units) }} + {{ temperature }} {{ locationTime }} @@ -68,15 +68,13 @@ export default { } return `${this.temp} ${unit}`; }, - }, - created() { - this.fetchWeather(); - }, - computed: { locationTime: function () { return this.calcTime(this.timezoneOffset); }, }, + created() { + this.fetchWeather(); + }, methods: { fetchWeather: async function () { let locationQuery; @@ -89,7 +87,11 @@ export default { } const apiKey = this.item.apikey || this.item.apiKey; - const url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${apiKey}&units=${this.item.units}`; + + let url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${apiKey}&units=${this.item.units}`; + if (this.item.endpoint) { + url = this.item.endpoint; + } fetch(url) .then((response) => { if (!response.ok) { diff --git a/src/components/services/Ping.vue b/src/components/services/Ping.vue index 07bc053..e2db050 100644 --- a/src/components/services/Ping.vue +++ b/src/components/services/Ping.vue @@ -29,9 +29,12 @@ export default { }, methods: { fetchStatus: async function () { - const method = typeof this.item.method === 'string' ? this.item.method.toUpperCase() : 'HEAD'; + const method = + typeof this.item.method === "string" + ? this.item.method.toUpperCase() + : "HEAD"; - if (!['GET', 'HEAD', 'OPTION'].includes(method)) { + if (!["GET", "HEAD", "OPTION"].includes(method)) { console.error(`Ping: ${method} is not a supported HTTP method`); return; } -- cgit v1.2.3