From 5341db7026554d2bd32f18b86e392cd90ad22759 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Tue, 11 Aug 2020 17:15:23 +0200 Subject: [PATCH] Use proper API calling method --- lib/www/client/source/src/views/Map.vue | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/lib/www/client/source/src/views/Map.vue b/lib/www/client/source/src/views/Map.vue index 1a78d58..84ddc24 100644 --- a/lib/www/client/source/src/views/Map.vue +++ b/lib/www/client/source/src/views/Map.vue @@ -170,20 +170,11 @@ export default { methods: { async fitProjectBounds () { - try { - this.loading = true; - const res = await fetch(`${this.$root.apiUrl}/project/${this.$route.params.project}/gis`); - if (res.ok) { - const bbox = new L.GeoJSON(await res.json()); - map.fitBounds(bbox.getBounds()); - } else { - this.$root.showSnack(res.statusText, "warning"); - } - } catch (err) { - this.$root.showSnack(err, "error") - } finally { - this.loading = false; - } + this.loading = true; + const res = await this.api([`/project/${this.$route.params.project}/gis`]); + const bbox = new L.GeoJSON(res); + map.fitBounds(bbox.getBounds()); + this.loading = false; }, async refreshLayers (layerset) {