Added libs
This commit is contained in:
43
rendezvous/vue/api/api.js
Normal file
43
rendezvous/vue/api/api.js
Normal file
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
},
|
||||
}
|
||||
Reference in New Issue
Block a user