This commit is contained in:
mitch ross
2021-05-12 10:50:58 -04:00
committed by Mitch Ross
parent b282e320cc
commit 13fb9b2d0a
4 changed files with 14 additions and 4 deletions
+7 -2
View File
@@ -34,8 +34,8 @@ export default function Event({ eventId }) {
debugger;
const response = await fetch(`${apiHost}/api/events/${eventId}`, { method: 'DELETE' });
debugger;
const deleteEvent = await response.json();
const deleteEvent = await getJSON(response)
debugger;
success = deleteEvent.success;
debugger;
setDeleteStatus(success ? FetchStatus.LOADED : FetchStatus.ERROR);
@@ -44,6 +44,11 @@ export default function Event({ eventId }) {
setDeleteStatus(FetchStatus.ERROR);
}
async function getJSON(response) {
if (response.status === 204) return {success: true};
return response.json();
}
if (success) {
setDeleteStatus(FetchStatus.LOADED);
setShowDialog(false);