[+] 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 { getUserSubdomain } from "../../service/firebase";
import '../../service/api.tsx'; import '../../service/api.tsx';
import serviiApi from "../../service/api.tsx"; import serviiApi from "../../service/api.tsx";
import Api from "../../service/api.tsx";
const DashboardPage = ({ user }) => { const DashboardPage = ({ user }) => {

View File

@ -44,16 +44,16 @@ interface CommandRequest {
} }
enum serviiRequest { enum serviiRequest {
setSubdomain = 'setSubdomain', setSubdomain = 'SetSubdomain',
fetchServers = 'fetchServers', fetchServers = 'FetchServers',
accountCreate = 'accountCreate', accountCreate = 'AccountCreate',
serverCreate = 'serverCreate', serverCreate = 'ServerCreate',
serverDelete = 'serverDelete', serverDelete = 'ServerDelete',
accountDelete = 'accountDelete', accountDelete = 'AccountDelete',
serverRun = 'serverRun', serverRun = 'ServerRun',
serverStop = 'serverStop', serverStop = 'ServerStop',
updateProperty = 'updateProperty', updateProperty = 'UpdateProperty',
command = 'command', command = 'Command',
} }
class serviiApi { class serviiApi {
@ -67,14 +67,17 @@ class serviiApi {
}, },
body: JSON.stringify(body), body: JSON.stringify(body),
}); });
const status = response.status const status: number = response.status
const json = await response.json(); const json = await response.json();
if ('message' in json) { if (json.message === undefined) {
return {return_code: status, message: json.message}; 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: "Couldn't find an available API, we're sorry for the inconvenience."};
} }
return {return_code: status, message: json};
}
return {return_code: status, message: json.message};
}
private static token(): string { private static token(): string {
const currentUser = getAuth().currentUser; const currentUser = getAuth().currentUser;