open-webui/src/lib/apis/index.ts

24 lines
437 B
TypeScript
Raw Normal View History

2023-12-26 20:32:22 +01:00
import { WEBUI_API_BASE_URL } from '$lib/constants';
export const getBackendConfig = async () => {
2023-12-26 12:28:30 +01:00
let error = null;
2023-12-26 20:32:22 +01:00
const res = await fetch(`${WEBUI_API_BASE_URL}/`, {
2023-12-26 12:28:30 +01:00
method: 'GET',
headers: {
2023-12-26 20:32:22 +01:00
'Content-Type': 'application/json'
2023-12-26 12:28:30 +01:00
}
})
.then(async (res) => {
if (!res.ok) throw await res.json();
return res.json();
})
2023-12-26 20:32:22 +01:00
.catch((err) => {
console.log(err);
error = err;
2023-12-26 12:28:30 +01:00
return null;
});
2023-12-26 20:32:22 +01:00
return res;
2023-12-26 12:28:30 +01:00
};