async function refresh_overview(server_address) {
	try {
		const response = await fetch(`${server_address}overview`);
		if (response.ok) {
			const data = await response.json();
			if (!("error" in data)) {
				return { overview: data, error: null };
			} else {
				return { overview: null, error: data };
			}
		} else {
			return { overview: null, error: null };
		}
	} catch (e) {
		return { overview: null, error: e };
	}
}

async function refresh_hints(server_address) {
	const response = await fetch(`${server_address}hints`);
	const data = await response.json();
	return data;
}

async function refresh_checks(server_address) {
	const response = await fetch(`${server_address}items`);
	const data = await response.json();
	return data;
}

async function refresh_entrances(server_address) {
	const response = await fetch(`${server_address}doors`);
	const data = await response.json();
	return data;
}

export default {
	refresh_overview,
	refresh_checks,
	refresh_entrances,
	refresh_hints,
};
