initial commit for having a backup
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
const URLleaderboard = "http://localhost:8080/racetimer_endpoints-1.0/api/timers/leaderboard";
|
||||
const URLPlayer = "http://localhost:8080/racetimer_endpoints-1.0/api/timers/player/";
|
||||
const URLPlayerMaps = "http://localhost:8080/racetimer_endpoints-1.0/api/timers/player/maps/";
|
||||
const URLMaps = "http://localhost:8080/racetimer_endpoints-1.0/api/timers/map/";
|
||||
function makeOptions(method, body) {
|
||||
var opts = {
|
||||
method: method,
|
||||
headers: {
|
||||
"Content-type": "application/json"
|
||||
}
|
||||
};
|
||||
if (body) {
|
||||
opts.body = JSON.stringify(body);
|
||||
}
|
||||
return opts;
|
||||
}
|
||||
|
||||
function handleHttpErrors(res) {
|
||||
if (!res.ok) {
|
||||
return Promise.reject({ status: res.status, fullError: res.json() });
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
||||
class DataFacade {
|
||||
getLeaderBoard = () => {
|
||||
return fetch(URLleaderboard).then(handleHttpErrors);
|
||||
};
|
||||
|
||||
getPlayer = steamID => {
|
||||
return fetch(URLPlayer + steamID).then(handleHttpErrors);
|
||||
}
|
||||
|
||||
getPlayerTimes = steamID => {
|
||||
return fetch(URLPlayerMaps + steamID).then(handleHttpErrors);
|
||||
}
|
||||
|
||||
getMapTimes = (mapname, stage) => {
|
||||
return fetch(URLMaps + mapname + "/" + stage).then(handleHttpErrors);
|
||||
}
|
||||
}
|
||||
|
||||
export default new DataFacade();
|
||||
Reference in New Issue
Block a user