fix locales versioning in backend client

This commit is contained in:
Hazelnoot 2024-10-15 21:32:03 -04:00
parent 9b06347882
commit 7431866d86
4 changed files with 27 additions and 57 deletions

View file

@ -6,36 +6,6 @@
'use strict';
window.onload = async () => {
const account = JSON.parse(localStorage.getItem('account'));
const i = account.token;
const api = (endpoint, data = {}) => {
const promise = new Promise((resolve, reject) => {
// Append a credential
if (i) data.i = i;
// Send request
window.fetch(endpoint.indexOf('://') > -1 ? endpoint : `/api/${endpoint}`, {
method: 'POST',
body: JSON.stringify(data),
credentials: 'omit',
cache: 'no-cache'
}).then(async (res) => {
const body = res.status === 204 ? null : await res.json();
if (res.status === 200) {
resolve(body);
} else if (res.status === 204) {
resolve();
} else {
reject(body.error);
}
}).catch(reject);
});
return promise;
};
const content = document.getElementById('content');
document.getElementById('ls').addEventListener('click', () => {