43 lines
1.3 KiB
JavaScript
43 lines
1.3 KiB
JavaScript
const apiUrl = "/api/rendezvous";
|
|
|
|
export const rendezvousApi = {
|
|
|
|
async runServer(user){
|
|
const data = {"user": user};
|
|
const requestOptions = {
|
|
method: 'POST',
|
|
headers: {'Content-Type': 'application/json',},
|
|
body: JSON.stringify(data),
|
|
};
|
|
try {
|
|
const response = await fetch(apiUrl+"/server", requestOptions);
|
|
if (!response.ok) {
|
|
const errorText = await response.text();
|
|
throw new Error(`Error starting server: ${response.status} - ${errorText}`);
|
|
}
|
|
|
|
const result = await response.json();
|
|
return result;
|
|
|
|
} catch (error) {
|
|
console.error("Error starting server:", error);
|
|
throw error;
|
|
}
|
|
|
|
},
|
|
|
|
async getServerStatus(){
|
|
try {
|
|
const response = await fetch(apiUrl+"/server")
|
|
if (!response.ok) {
|
|
const errorText = await response.text();
|
|
throw new Error(`Error fetching users: ${response.status} - ${errorText}`);
|
|
}
|
|
const result = await response.json()
|
|
return result;
|
|
} catch (error) {
|
|
console.error("Error fetching configs:", error);
|
|
throw error;
|
|
}
|
|
},
|
|
} |