Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 5 additions & 20 deletions dashboard/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,34 +44,19 @@
// -------------------------------------------------------------------------
// Utilities
// -------------------------------------------------------------------------
function apiJSON(url, options, timeoutMs) {
const controller = new AbortController();
const timer = setTimeout(function () { controller.abort(); }, timeoutMs || 15000);
return fetch(url, Object.assign({ signal: controller.signal }, options || {}))
.then(function (response) {
return response.text().then(function (body) {
clearTimeout(timer);
let parsed = null;
try { parsed = body ? JSON.parse(body) : null; } catch (err) { parsed = body; }
if (!response.ok) {
const detail = parsed && parsed.detail ? parsed.detail : (body || response.statusText);
throw new Error(detail);
}
return parsed;
});
});
}

// Use SDK.fetchJSON so the session token (X-Hermes-Session-Token) is
// automatically injected — required since Hermes v2026.5.16 removed the
// /api/plugins/ auth exemption (PR #23220).
function postJSON(path, payload) {
return apiJSON(API_BASE + path, {
return SDK.fetchJSON(API_BASE + path, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
}

function getJSON(path) {
return apiJSON(API_BASE + path, { method: 'GET' });
return SDK.fetchJSON(API_BASE + path, { method: 'GET' });
}

function text(value, fallback) {
Expand Down