diff options
author | Andreas Waschinski <25221082+waschinski@users.noreply.github.com> | 2021-07-28 16:10:11 +0200 |
---|---|---|
committer | Andreas Waschinski <25221082+waschinski@users.noreply.github.com> | 2021-07-28 16:10:11 +0200 |
commit | 64ac4c48d50d8ed3eda8ae2dfc37e4453c84cd90 (patch) | |
tree | 69f0dbb3796357434b3d75a8a6e0dde7fef0c15f | |
parent | 73a102f3facf8716ba890423260bd733701f0c06 (diff) | |
download | homer-64ac4c48d50d8ed3eda8ae2dfc37e4453c84cd90.tar.gz homer-64ac4c48d50d8ed3eda8ae2dfc37e4453c84cd90.tar.zst homer-64ac4c48d50d8ed3eda8ae2dfc37e4453c84cd90.zip |
Statistics now also need the token for authentication
-rw-r--r-- | src/components/services/Mealie.vue | 55 |
1 files changed, 28 insertions, 27 deletions
diff --git a/src/components/services/Mealie.vue b/src/components/services/Mealie.vue index 7224bf4..acff1fb 100644 --- a/src/components/services/Mealie.vue +++ b/src/components/services/Mealie.vue | |||
@@ -55,35 +55,36 @@ export default { | |||
55 | fetchStatus: async function () { | 55 | fetchStatus: async function () { |
56 | if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing | 56 | if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing |
57 | var apikey = this.item.apikey; | 57 | var apikey = this.item.apikey; |
58 | if (apikey) { | 58 | this.meal = await fetch(`${this.item.url}/api/meal-plans/today/`, { |
59 | const url = `${this.item.url}/api/meal-plans/today/`; | 59 | headers: { |
60 | this.meal = await fetch(url, { | 60 | "Authorization": "Bearer " + this.item.apikey, |
61 | headers: { | 61 | "Accept": "application/json" |
62 | "Authorization": "Bearer " + this.item.apikey, | 62 | } |
63 | "Accept": "application/json" | 63 | }) |
64 | } | 64 | .then(function(response) { |
65 | }) | 65 | if (!response.ok) { |
66 | .then(function(response) { | 66 | throw new Error("Not 2xx response") |
67 | if (!response.ok) { | 67 | } else { |
68 | throw new Error("Not 2xx response") | 68 | if (response != null) { |
69 | } else { | ||
70 | if (response != null) { | ||
71 | return response.json(); | ||
72 | } | ||
73 | } | ||
74 | }) | ||
75 | .catch((e) => console.log(e)); | ||
76 | } | ||
77 | const url = `${this.item.url}/api/debug/statistics/`; | ||
78 | this.stats = await fetch(url) | ||
79 | .then(function(response) { | ||
80 | if (!response.ok) { | ||
81 | throw new Error("Not 2xx response") | ||
82 | } else { | ||
83 | return response.json(); | 69 | return response.json(); |
84 | } | 70 | } |
85 | }) | 71 | } |
86 | .catch((e) => console.log(e)); | 72 | }) |
73 | .catch((e) => console.log(e)); | ||
74 | this.stats = await fetch(`${this.item.url}/api/debug/statistics/`, { | ||
75 | headers: { | ||
76 | "Authorization": "Bearer " + this.item.apikey, | ||
77 | "Accept": "application/json" | ||
78 | } | ||
79 | }) | ||
80 | .then(function(response) { | ||
81 | if (!response.ok) { | ||
82 | throw new Error("Not 2xx response") | ||
83 | } else { | ||
84 | return response.json(); | ||
85 | } | ||
86 | }) | ||
87 | .catch((e) => console.log(e)); | ||
87 | }, | 88 | }, |
88 | }, | 89 | }, |
89 | }; | 90 | }; |