[+] Api Fix

This commit is contained in:
Charles Le Maux 2024-07-03 16:26:51 +01:00
parent 6cf8488476
commit 3886029191
2 changed files with 18 additions and 14 deletions

View File

@ -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 }) => {

View File

@ -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 {