Helper func for lottery/by-name.
This commit is contained in:
16
src/api.js
16
src/api.js
@@ -333,6 +333,19 @@ const historyAll = () => {
|
||||
});
|
||||
}
|
||||
|
||||
const getWinnerByName = (name) => {
|
||||
const encodedName = encodeURIComponent(name)
|
||||
const url = new URL(`/api/lottery/by-name/${name}`, BASE_URL);
|
||||
|
||||
return fetch(url.href).then(resp => {
|
||||
if (resp.ok) {
|
||||
return resp.json();
|
||||
} else {
|
||||
return handleErrors(resp);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export {
|
||||
statistics,
|
||||
colorStatistics,
|
||||
@@ -364,5 +377,6 @@ export {
|
||||
finishedDraw,
|
||||
getAmIWinner,
|
||||
postWineChosen,
|
||||
historyAll
|
||||
historyAll,
|
||||
getWinnerByName
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user