diff --git a/docs/customservices.md b/docs/customservices.md index a0b143e..d7c5212 100644 --- a/docs/customservices.md +++ b/docs/customservices.md @@ -29,6 +29,6 @@ items: location: "Amsterdam" # your location. apiKey: "<---insert-api-key-here--->" # insert your own API key here. Request one from https://openweathermap.org/api. units: "metric" # units to display temperature. Can be one of: metric, imperial, kelvin. Defaults to kelvin. - background: "square" choose which type of background you want behind the image. Can be one of: square, cicle, none. Defaults to none. + background: "square" # choose which type of background you want behind the image. Can be one of: square, cicle, none. Defaults to none. type: "OpenWeather" ``` diff --git a/src/components/services/OpenWeather.vue b/src/components/services/OpenWeather.vue index c535a89..8029716 100644 --- a/src/components/services/OpenWeather.vue +++ b/src/components/services/OpenWeather.vue @@ -1,7 +1,7 @@

@@ -49,7 +54,9 @@ export default { item: Object, }, data: () => ({ + error: false, api: { + id: "", name: "", weather: [ { @@ -65,8 +72,14 @@ export default { }, }), computed: { - temp: function () { + locationId: function () { if (this.api) { + return this.api.id; + } + return ""; + }, + temp: function () { + if (this.api && this.api.main.temp !== "") { return parseInt(this.api.main.temp).toFixed(1); } return ""; @@ -92,13 +105,19 @@ export default { const url = `https://api.openweathermap.org/data/2.5/weather?q=${this.item.location}&appid=${this.item.apiKey}&units=${this.item.units}`; this.api = await fetch(url) .then((response) => response.json()) - .catch((e) => console.log(e)); + .catch((e) => { + this.error = true; + console.log(e) + }); }, }, };