forked from extern/homer
Statistics now also need the token for authentication
This commit is contained in:
parent
73a102f3fa
commit
64ac4c48d5
@ -55,35 +55,36 @@ export default {
|
|||||||
fetchStatus: async function () {
|
fetchStatus: async function () {
|
||||||
if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing
|
if (this.item.subtitle != null) return; // omitting unnecessary ajax call as the subtitle is showing
|
||||||
var apikey = this.item.apikey;
|
var apikey = this.item.apikey;
|
||||||
if (apikey) {
|
this.meal = await fetch(`${this.item.url}/api/meal-plans/today/`, {
|
||||||
const url = `${this.item.url}/api/meal-plans/today/`;
|
headers: {
|
||||||
this.meal = await fetch(url, {
|
"Authorization": "Bearer " + this.item.apikey,
|
||||||
headers: {
|
"Accept": "application/json"
|
||||||
"Authorization": "Bearer " + this.item.apikey,
|
}
|
||||||
"Accept": "application/json"
|
})
|
||||||
}
|
.then(function(response) {
|
||||||
})
|
if (!response.ok) {
|
||||||
.then(function(response) {
|
throw new Error("Not 2xx response")
|
||||||
if (!response.ok) {
|
} else {
|
||||||
throw new Error("Not 2xx response")
|
if (response != null) {
|
||||||
} 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 {
|
|
||||||
return response.json();
|
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));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user