incomplete
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user