You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

24 lines
606 B

import type UIState from "$lib/models/uistate";
export default async function fetchLucifer<T>(path: string, init?: RequestInit): Promise<T> {
const url = import.meta.env.VITE_LUCIFER4_BACKEND_URL + "/" + path;
console.log(url);
const res = await fetch(url, init);
if (res.status !== 200) {
if (res.headers.get("Content-Type")?.includes("application/json")) {
throw await res.json();
} else {
throw await res.text();
}
}
const json = await res.json();
return json as T;
}
export async function fetchUIState(): Promise<UIState> {
return fetchLucifer("state");
}