Now requestAll returns object w/ wine within.
Also some housekeeping.
This commit is contained in:
@@ -26,7 +26,8 @@ const allRequestedWines = () => {;
|
|||||||
return fetch("/api/request/all")
|
return fetch("/api/request/all")
|
||||||
.then(resp => {
|
.then(resp => {
|
||||||
const isAdmin = resp.headers.get("vinlottis-admin") == "true";
|
const isAdmin = resp.headers.get("vinlottis-admin") == "true";
|
||||||
return Promise.all([resp.json(), isAdmin]);
|
const getWinesFromBody = (resp) => resp.json().then(body => body.wines);
|
||||||
|
return Promise.all([getWinesFromBody(resp), isAdmin]);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -109,8 +110,7 @@ const deleteRequestedWine = wineToBeDeleted => {
|
|||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json"
|
"Content-Type": "application/json"
|
||||||
},
|
},
|
||||||
method: "DELETE",
|
method: "DELETE"
|
||||||
body: JSON.stringify(wineToBeDeleted)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return fetch("api/request/" + wineToBeDeleted.id, options)
|
return fetch("api/request/" + wineToBeDeleted.id, options)
|
||||||
@@ -148,14 +148,12 @@ const attendees = () => {
|
|||||||
|
|
||||||
const requestNewWine = (wine) => {
|
const requestNewWine = (wine) => {
|
||||||
const options = {
|
const options = {
|
||||||
body: JSON.stringify({
|
method: "POST",
|
||||||
wine: wine
|
|
||||||
}),
|
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
'Accept': 'application/json',
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
},
|
},
|
||||||
method: "post"
|
body: JSON.stringify({ wine })
|
||||||
}
|
}
|
||||||
|
|
||||||
return fetch("/api/request/new-wine", options)
|
return fetch("/api/request/new-wine", options)
|
||||||
|
|||||||
Reference in New Issue
Block a user