diff --git a/src/pages/DashboardPage/DashboardPage.jsx b/src/pages/DashboardPage/DashboardPage.jsx index 7dcc299..2adbfdb 100644 --- a/src/pages/DashboardPage/DashboardPage.jsx +++ b/src/pages/DashboardPage/DashboardPage.jsx @@ -6,6 +6,7 @@ import NoServer from '../NoServer/NoServer'; import { getUserSubdomain } from "../../service/firebase"; import '../../service/api.tsx'; import serviiApi from "../../service/api.tsx"; +import Api from "../../service/api.tsx"; const DashboardPage = ({ user }) => { diff --git a/src/service/api.tsx b/src/service/api.tsx index 758e2b0..bdcfc88 100644 --- a/src/service/api.tsx +++ b/src/service/api.tsx @@ -44,16 +44,16 @@ interface CommandRequest { } enum serviiRequest { - setSubdomain = 'setSubdomain', - fetchServers = 'fetchServers', - accountCreate = 'accountCreate', - serverCreate = 'serverCreate', - serverDelete = 'serverDelete', - accountDelete = 'accountDelete', - serverRun = 'serverRun', - serverStop = 'serverStop', - updateProperty = 'updateProperty', - command = 'command', + setSubdomain = 'SetSubdomain', + fetchServers = 'FetchServers', + accountCreate = 'AccountCreate', + serverCreate = 'ServerCreate', + serverDelete = 'ServerDelete', + accountDelete = 'AccountDelete', + serverRun = 'ServerRun', + serverStop = 'ServerStop', + updateProperty = 'UpdateProperty', + command = 'Command', } class serviiApi { @@ -67,13 +67,16 @@ class serviiApi { }, body: JSON.stringify(body), }); - const status = response.status + const status: number = response.status const json = await response.json(); - if ('message' in json) { - return {return_code: status, message: json.message}; + if (json.message === undefined) { + if (!(endpoint === serviiRequest.fetchServers)){ + return {return_code: status, message: "Couldn't find an available API, we're sorry for the inconvenience."}; + } + return {return_code: status, message: json}; } - return {return_code: status, message: "Couldn't find an available API, we're sorry for the inconvenience."}; + return {return_code: status, message: json.message}; } private static token(): string {