incomplete

This commit is contained in:
2023-08-04 15:48:48 +03:00
parent 7fbb71a4c1
commit fdcba863c2
13 changed files with 239 additions and 43 deletions

View File

@@ -1,8 +1,12 @@
import { routes } from './routes.js';
let DEBUG = false;
let DEBUG = true;
window.DEBUG = DEBUG;
let SERVER_URL;
if (DEBUG) SERVER_HOST = 'localhost';
else SERVER_HOST = 'a2s.su';
/* main */
window.onload = function () {
let app = document.documentElement;
@@ -69,3 +73,21 @@ const location_handler = async () => {
document.querySelector('#autorun').innerHTML = '';
}
};
function get_from_api(callback, api_method = '', params = {}) {
respone = '';
if (api_method == '') {
console.log('wrong method');
} else {
fetch(`http://${SERVER_HOST}:3000/api/v1.0/${api_method}`)
.then((response) => {
return response.json();
})
.then((data) => {
callback(data);
})
.catch((err) => console.warn('Something went wrong.', err));
}
}
window.get_from_api = get_from_api;