diff --git a/GUI/ETVR/src/store/context/api/index.tsx b/GUI/ETVR/src/store/context/api/index.tsx index ed8dc07..9721552 100644 --- a/GUI/ETVR/src/store/context/api/index.tsx +++ b/GUI/ETVR/src/store/context/api/index.tsx @@ -498,18 +498,19 @@ export const AppAPIProvider: Component = (props) => { setRESTStatus(RESTStatus.LOADING) try { + setRESTStatus(RESTStatus.ACTIVE) let parsedResponse: object = {} const response = await makeRequest(endpoint, deviceName, method) - if (response.status === 'ok') { - setRESTStatus(RESTStatus.ACTIVE) - - const unlisten = await listen('request-response', (event) => { - parsedResponse = JSON.parse(event.payload) - }) - - unlisten() - setRESTResponse(parsedResponse) + const unlisten = await listen('request-response', (event) => { + parsedResponse = JSON.parse(event.payload) + }) + if (response.status === 'error') { + setRESTStatus(RESTStatus.FAILED) + error(`[REST Request]: ${response.error}`) + return O.none } + unlisten() + setRESTResponse(parsedResponse) setRESTStatus(RESTStatus.COMPLETE) return O.some(parsedResponse) } catch (err) {