aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/components/services/OpenWeather.vue
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/services/OpenWeather.vue')
-rw-r--r--src/components/services/OpenWeather.vue16
1 files changed, 9 insertions, 7 deletions
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 @@
23 <p class="title is-4">{{ name }}</p> 23 <p class="title is-4">{{ name }}</p>
24 <p class="subtitle is-6"> 24 <p class="subtitle is-6">
25 <span> 25 <span>
26 {{ temp | tempSuffix(this.item.units) }} 26 {{ temperature }}
27 </span> 27 </span>
28 <span class="location-time"> 28 <span class="location-time">
29 {{ locationTime }} 29 {{ locationTime }}
@@ -68,15 +68,13 @@ export default {
68 } 68 }
69 return `${this.temp} ${unit}`; 69 return `${this.temp} ${unit}`;
70 }, 70 },
71 },
72 created() {
73 this.fetchWeather();
74 },
75 computed: {
76 locationTime: function () { 71 locationTime: function () {
77 return this.calcTime(this.timezoneOffset); 72 return this.calcTime(this.timezoneOffset);
78 }, 73 },
79 }, 74 },
75 created() {
76 this.fetchWeather();
77 },
80 methods: { 78 methods: {
81 fetchWeather: async function () { 79 fetchWeather: async function () {
82 let locationQuery; 80 let locationQuery;
@@ -89,7 +87,11 @@ export default {
89 } 87 }
90 88
91 const apiKey = this.item.apikey || this.item.apiKey; 89 const apiKey = this.item.apikey || this.item.apiKey;
92 const url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${apiKey}&units=${this.item.units}`; 90
91 let url = `https://api.openweathermap.org/data/2.5/weather?${locationQuery}&appid=${apiKey}&units=${this.item.units}`;
92 if (this.item.endpoint) {
93 url = this.item.endpoint;
94 }
93 fetch(url) 95 fetch(url)
94 .then((response) => { 96 .then((response) => {
95 if (!response.ok) { 97 if (!response.ok) {