From 0dabfe53ba4e30ba19da460f1907ffadc0fd9d4a Mon Sep 17 00:00:00 2001 From: Ilija Lazoroski Date: Mon, 1 Aug 2022 14:16:25 +0200 Subject: [PATCH] UI: Check if response is successful instead of http status code --- .../src/components/ui-components/IslandResetModal.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx index e3f798799..67f3256b4 100644 --- a/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx +++ b/monkey/monkey_island/cc/ui/src/components/ui-components/IslandResetModal.tsx @@ -96,7 +96,7 @@ const IslandResetModal = (props: Props) => { function clearSimulationData(callback: () => void) { auth.authFetch('/api/clear-simulation-data', {method: 'POST'}) .then(res => { - if (res.status === 200) { + if (res.ok) { callback(); } }) @@ -104,19 +104,19 @@ const IslandResetModal = (props: Props) => { function resetAll() { auth.authFetch('/api/reset-agent-configuration', {method: 'POST'}) .then(res => { - if (res.status === 200) { + if (res.ok) { return auth.authFetch('/api/clear-simulation-data', {method: 'POST'}) }}) .then(res => { - if (res.status === 200) { + if (res.ok) { return auth.authFetch('/api/propagation-credentials/configured-credentials', {method: 'PUT', body:'[]'}) }}) .then(res => { - if (res.status === 200) { + if (res.ok) { return auth.authFetch('/api/island/mode', {method: 'PUT', body: '{"mode": "unset"}'}) }}) .then(res => { - if (res.status !== 200) { + if (!res.ok) { throw 'Error resetting the simulation' } })