mirror of
https://github.com/open-webui/open-webui
synced 2024-11-09 02:00:03 +00:00
80 lines
1.3 KiB
TypeScript
80 lines
1.3 KiB
TypeScript
import { WEBUI_BASE_URL } from '$lib/constants';
|
|
|
|
export const getBackendConfig = async () => {
|
|
let error = null;
|
|
|
|
const res = await fetch(`${WEBUI_BASE_URL}/api/config`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
})
|
|
.then(async (res) => {
|
|
if (!res.ok) throw await res.json();
|
|
return res.json();
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
error = err;
|
|
return null;
|
|
});
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return res;
|
|
};
|
|
|
|
export const getChangelog = async () => {
|
|
let error = null;
|
|
|
|
const res = await fetch(`${WEBUI_BASE_URL}/api/changelog`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
})
|
|
.then(async (res) => {
|
|
if (!res.ok) throw await res.json();
|
|
return res.json();
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
error = err;
|
|
return null;
|
|
});
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return res;
|
|
};
|
|
|
|
export const getVersionUpdates = async () => {
|
|
let error = null;
|
|
|
|
const res = await fetch(`${WEBUI_BASE_URL}/api/version/updates`, {
|
|
method: 'GET',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
}
|
|
})
|
|
.then(async (res) => {
|
|
if (!res.ok) throw await res.json();
|
|
return res.json();
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
error = err;
|
|
return null;
|
|
});
|
|
|
|
if (error) {
|
|
throw error;
|
|
}
|
|
|
|
return res;
|
|
};
|