Files
video-shader-toys/ui/src/api/controlApi.js
Aiden 8ffc011ca0
All checks were successful
CI / React UI Build (push) Successful in 11s
CI / Native Windows Build And Tests (push) Successful in 2m46s
CI / Windows Release Package (push) Has been skipped
Added config editor in front end
2026-05-30 19:33:40 +10:00

26 lines
697 B
JavaScript

export function postJson(path, payload) {
return fetch(path, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
}
export async function fetchJson(path) {
const response = await fetch(path);
const body = await response.json();
if (!response.ok) {
throw new Error(body?.error || `Request failed: ${response.status}`);
}
return body;
}
export async function postJsonResult(path, payload) {
const response = await postJson(path, payload);
const body = await response.json();
if (!response.ok || body?.ok === false) {
throw new Error(body?.error || `Request failed: ${response.status}`);
}
return body;
}