index.ts 437 Bytes
Newer Older
Timothy J. Baek's avatar
Timothy J. Baek committed
1
2
3
import { WEBUI_API_BASE_URL } from '$lib/constants';

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

Timothy J. Baek's avatar
Timothy J. Baek committed
6
	const res = await fetch(`${WEBUI_API_BASE_URL}/`, {
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
	return res;
23
};