diff --git a/src/Geopilot.Frontend/src/api/apiContext.tsx b/src/Geopilot.Frontend/src/api/apiContext.tsx index 05d158ae..a32639fc 100644 --- a/src/Geopilot.Frontend/src/api/apiContext.tsx +++ b/src/Geopilot.Frontend/src/api/apiContext.tsx @@ -19,7 +19,7 @@ export const ApiProvider: FC = ({ children }) => { if (response.ok) { const responseContentType = response.headers.get("content-type"); - if (responseContentType?.indexOf("application/json") !== -1) { + if (responseContentType !== null && responseContentType?.indexOf("application/json") !== -1) { return (await response.json()) as T; } else if (!options.responseType || responseContentType?.includes(options.responseType)) { return (await response.text()) as T; diff --git a/src/Geopilot.Frontend/src/pages/admin/deliveryOverview.tsx b/src/Geopilot.Frontend/src/pages/admin/deliveryOverview.tsx index 393e9a00..0e447405 100644 --- a/src/Geopilot.Frontend/src/pages/admin/deliveryOverview.tsx +++ b/src/Geopilot.Frontend/src/pages/admin/deliveryOverview.tsx @@ -74,8 +74,8 @@ export const DeliveryOverview = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, []); - async function handleDelete() { - for (const row of selectedRows) { + function handleDelete() { + const deletePromises = selectedRows.map(row => fetchApi("/api/v1/delivery/" + row, { method: "DELETE" }).catch((error: ApiError) => { if (error.status === 404) { showAlert(t("deliveryOverviewDeleteIdNotExistError", { id: row }), "error"); @@ -84,9 +84,12 @@ export const DeliveryOverview = () => { } else { showAlert(t("deliveryOverviewDeleteError", { error: error }), "error"); } - }); - } - await loadDeliveries(); + }), + ); + + Promise.all(deletePromises).then(() => { + loadDeliveries(); + }); } return (