UI: Check if response is successful instead of http status code

This commit is contained in:
Ilija Lazoroski 2022-08-01 14:16:25 +02:00
parent b69b0468c5
commit 0dabfe53ba
1 changed files with 5 additions and 5 deletions

View File

@ -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'
}
})