Statistics now also need the token for authentication

This commit is contained in:
Andreas Waschinski 2021-07-28 16:10:11 +02:00
parent 73a102f3fa
commit 64ac4c48d5

View File

@ -55,9 +55,7 @@ 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, {
this.meal = await fetch(`${this.item.url}/api/meal-plans/today/`, {
headers: {
"Authorization": "Bearer " + this.item.apikey,
"Accept": "application/json"
@ -73,9 +71,12 @@ export default {
}
})
.catch((e) => console.log(e));
this.stats = await fetch(`${this.item.url}/api/debug/statistics/`, {
headers: {
"Authorization": "Bearer " + this.item.apikey,
"Accept": "application/json"
}
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")