frontend: useServers(), useOwners()

This commit is contained in:
Frank Agerholm 2026-01-25 19:55:55 +01:00
commit 43de7bc9b5
No known key found for this signature in database
5 changed files with 70 additions and 61 deletions

View file

@ -0,0 +1,33 @@
import { ref } from "vue"
import { isUnauthorized } from "~/utils/auth"
export function useServers() {
const servers = ref([])
const loading = ref(false)
const error = ref("")
const { apiFetch } = useApi()
async function loadServers() {
loading.value = true
error.value = ""
const result = await apiFetch("/servers")
if (isUnauthorized(result)) {
loading.value = false
return result
}
servers.value = result
loading.value = false
return result
}
return {
servers,
loading,
error,
loadServers
}
}