You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Cryptid/cryptide_project/src/services/ScoreboardService.tsx

106 lines
3.3 KiB

import {ADRESSE_DBSERVER} from '../AdressSetup';
class ScoreboardService {
// ------------------------------ GET ------------------------------
// ----------------------------- DAILY -----------------------------
// ----------------------------- STATS -----------------------------
static async getDailyMastermindStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyMastermind', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getDailyOnlineStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getDailyOnline', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
// ------------------------------ GET ------------------------------
// ----------------------------- WEEKLY ----------------------------
// ----------------------------- STATS -----------------------------
static async getWeeklyMastermindStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyMastermind', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
static async getWeeklyOnlineStats() {
try {
const response = await fetch(ADRESSE_DBSERVER + '/scoreboard/getWeeklyOnline', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
credentials: 'include',
});
if (response.ok) {
const result = await response.json();
return result;
} else {
const errorResponse = await response.json();
throw new Error(errorResponse.error);
}
} catch (error) {
console.error(error);
throw error;
}
}
}
export default ScoreboardService;