fix frontend invoke result handling
This commit is contained in:
@@ -95,6 +95,11 @@
|
||||
if (!response.ok) throw new Error((data && (data.detail || data.message)) || `request failed: ${response.status}`);
|
||||
return data;
|
||||
}
|
||||
function unwrapInvokeResponse(payload) {
|
||||
return payload && typeof payload === 'object' && 'result' in payload
|
||||
? payload.result
|
||||
: payload;
|
||||
}
|
||||
function renderSkill() {
|
||||
const skill = (config.skills || []).find((item) => item.name === selected);
|
||||
skillNameEl.textContent = selected;
|
||||
@@ -125,9 +130,10 @@
|
||||
resultEl.textContent = 'Running…';
|
||||
try {
|
||||
const args = JSON.parse(argsEl.value || '{}');
|
||||
const data = await requestJson(`${config.endpoints.invoke}/${encodeURIComponent(selected)}`, {
|
||||
const payload = await requestJson(`${config.endpoints.invoke}/${encodeURIComponent(selected)}`, {
|
||||
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ arguments: args })
|
||||
});
|
||||
const data = unwrapInvokeResponse(payload);
|
||||
resultEl.textContent = JSON.stringify(data, null, 2);
|
||||
} catch (err) {
|
||||
resultEl.textContent = err.message || String(err);
|
||||
|
||||
Reference in New Issue
Block a user