add is admin middleware

This commit is contained in:
Adrian Thompson
2020-09-07 15:53:03 +02:00
parent e060ff3aaa
commit 052b5007c2
4 changed files with 17 additions and 6 deletions

View File

@@ -29,7 +29,11 @@ const overallWineStatistics = () => {
const allRequestedWines = () => {
const url = new URL("/api/request/all", BASE_URL);
return fetch(url.href).then(resp => resp.json());
return fetch(url.href)
.then(resp => {
const isAdmin = resp.headers.get("Vinlottis-Admin") || false;
return Promise.all([resp.json(), isAdmin]);
});
};
const chartWinsByColor = () => {