Added config editor in front end
This commit is contained in:
@@ -5,3 +5,21 @@ export function postJson(path, payload) {
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user