"vscode:/vscode.git/clone" did not exist on "687c87d5cb6737e23ad79c63b541a21531428801"
index.ts 1.3 KB
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
import { WEBUI_BASE_URL } from '$lib/constants';
Timothy J. Baek's avatar
Timothy J. Baek committed
2
3

export const getBackendConfig = async () => {
4
5
	let error = null;

Timothy J. Baek's avatar
Timothy J. Baek committed
6
	const res = await fetch(`${WEBUI_BASE_URL}/api/config`, {
7
8
		method: 'GET',
		headers: {
Timothy J. Baek's avatar
Timothy J. Baek committed
9
			'Content-Type': 'application/json'
10
11
12
13
14
15
		}
	})
		.then(async (res) => {
			if (!res.ok) throw await res.json();
			return res.json();
		})
Timothy J. Baek's avatar
Timothy J. Baek committed
16
17
18
		.catch((err) => {
			console.log(err);
			error = err;
19
20
21
			return null;
		});

Timothy J. Baek's avatar
Timothy J. Baek committed
22
23
24
25
	if (error) {
		throw error;
	}

Timothy J. Baek's avatar
Timothy J. Baek committed
26
	return res;
27
};
Timothy J. Baek's avatar
Timothy J. Baek committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47

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;
		});

Timothy J. Baek's avatar
Timothy J. Baek committed
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
	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;
	}

Timothy J. Baek's avatar
Timothy J. Baek committed
78
79
	return res;
};