Versie 0.2.0
This commit is contained in:
commit
e77d8fd373
495 files changed
+81026
No files matched your search
@@ -0,0 +1,25 @@
|
||||
// Generated, do not edit. sha256:2d07cc9fa8245d2a586ce4b51503f9ca7d40676b66802c6c06d44ad790d35373
|
||||
import { CONFIG } from '../shared/config.js';
|
||||
import { t } from './i18n/index.js';
|
||||
import { serverFoutTekst } from './data/_rpc.js';
|
||||
|
||||
async function api(path, { method = 'GET', body = null } = {}) {
|
||||
const ctl = new AbortController();
|
||||
const timer = setTimeout(() => ctl.abort(), CONFIG.MARKET_SERVICE.CLIENT_TIMEOUT_MS);
|
||||
try {
|
||||
const res = await fetch(path, {
|
||||
method,
|
||||
signal: ctl.signal,
|
||||
...(body ? { headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(body) } : {}),
|
||||
});
|
||||
const json = await res.json().catch(() => null);
|
||||
if (!res.ok) throw new Error(serverFoutTekst(json) || `HTTP ${res.status}`);
|
||||
return json;
|
||||
} catch (e) {
|
||||
if (e.name === 'AbortError') throw new Error(t('common.backendSilent', { s: CONFIG.MARKET_SERVICE.CLIENT_TIMEOUT_MS / 1000 }));
|
||||
throw e;
|
||||
} finally { clearTimeout(timer); }
|
||||
}
|
||||
|
||||
export const status = () => api('/api/market/status');
|
||||
export const test = () => api('/api/market/test', { method: 'POST', body: {} });
|
||||
Reference in new issue
Block a user