]> git.immae.eu Git - github/bastienwirtz/homer.git/commitdiff
Statistics now also need the token for authentication
authorAndreas Waschinski <25221082+waschinski@users.noreply.github.com>
Wed, 28 Jul 2021 14:10:11 +0000 (16:10 +0200)
committerAndreas Waschinski <25221082+waschinski@users.noreply.github.com>
Wed, 28 Jul 2021 14:10:11 +0000 (16:10 +0200)
src/components/services/Mealie.vue

index 7224bf441a1fae6e4c8b71d3b0d82bcd843814db..acff1fba97dbde42119cba0617616cf4217e0acd 100644 (file)
@@ -55,35 +55,36 @@ export default {
     fetchStatus: async function () {
       if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing
       var apikey = this.item.apikey;
-      if (apikey) {
-        const url = `${this.item.url}/api/meal-plans/today/`;
-        this.meal = await fetch(url, {
-            headers: {
-              "Authorization": "Bearer " + this.item.apikey,
-              "Accept": "application/json"
-            }
-          })
-          .then(function(response) {
-            if (!response.ok) {
-              throw new Error("Not 2xx response")
-            } else {
-              if (response != null) {
-                return response.json();
-              }
-            }
-          })
-          .catch((e) => console.log(e));
-      }
-      const url = `${this.item.url}/api/debug/statistics/`;
-      this.stats = await fetch(url)
-        .then(function(response) {
-          if (!response.ok) {
-            throw new Error("Not 2xx response")
-          } else {
+      this.meal = await fetch(`${this.item.url}/api/meal-plans/today/`, {
+        headers: {
+          "Authorization": "Bearer " + this.item.apikey,
+          "Accept": "application/json"
+        }
+      })
+      .then(function(response) {
+        if (!response.ok) {
+          throw new Error("Not 2xx response")
+        } else {
+          if (response != null) {
             return response.json();
           }
-        })
-        .catch((e) => console.log(e));
+        }
+      })
+      .catch((e) => console.log(e));
+      this.stats = await fetch(`${this.item.url}/api/debug/statistics/`, {
+        headers: {
+          "Authorization": "Bearer " + this.item.apikey,
+          "Accept": "application/json"
+        }
+      })
+      .then(function(response) {
+        if (!response.ok) {
+          throw new Error("Not 2xx response")
+        } else {
+          return response.json();
+        }
+      })
+      .catch((e) => console.log(e));
     },
   },
 };