forked from p34709852/monkey
UI: Check if response is successful instead of http status code
This commit is contained in:
parent
b69b0468c5
commit
0dabfe53ba
|
@ -96,7 +96,7 @@ const IslandResetModal = (props: Props) => {
|
||||||
function clearSimulationData(callback: () => void) {
|
function clearSimulationData(callback: () => void) {
|
||||||
auth.authFetch('/api/clear-simulation-data', {method: 'POST'})
|
auth.authFetch('/api/clear-simulation-data', {method: 'POST'})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status === 200) {
|
if (res.ok) {
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -104,19 +104,19 @@ const IslandResetModal = (props: Props) => {
|
||||||
function resetAll() {
|
function resetAll() {
|
||||||
auth.authFetch('/api/reset-agent-configuration', {method: 'POST'})
|
auth.authFetch('/api/reset-agent-configuration', {method: 'POST'})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status === 200) {
|
if (res.ok) {
|
||||||
return auth.authFetch('/api/clear-simulation-data', {method: 'POST'})
|
return auth.authFetch('/api/clear-simulation-data', {method: 'POST'})
|
||||||
}})
|
}})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status === 200) {
|
if (res.ok) {
|
||||||
return auth.authFetch('/api/propagation-credentials/configured-credentials', {method: 'PUT', body:'[]'})
|
return auth.authFetch('/api/propagation-credentials/configured-credentials', {method: 'PUT', body:'[]'})
|
||||||
}})
|
}})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status === 200) {
|
if (res.ok) {
|
||||||
return auth.authFetch('/api/island/mode', {method: 'PUT', body: '{"mode": "unset"}'})
|
return auth.authFetch('/api/island/mode', {method: 'PUT', body: '{"mode": "unset"}'})
|
||||||
}})
|
}})
|
||||||
.then(res => {
|
.then(res => {
|
||||||
if (res.status !== 200) {
|
if (!res.ok) {
|
||||||
throw 'Error resetting the simulation'
|
throw 'Error resetting the simulation'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue