frontend: useServers(), useOwners()
This commit is contained in:
parent
9eb9be7318
commit
43de7bc9b5
5 changed files with 70 additions and 61 deletions
33
frontend/app/composables/useOwners.ts
Normal file
33
frontend/app/composables/useOwners.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { ref } from "vue"
|
||||
import { isUnauthorized } from "~/utils/auth"
|
||||
|
||||
export function useOwners() {
|
||||
const owners = ref([])
|
||||
const loading = ref(false)
|
||||
const error = ref("")
|
||||
|
||||
const { apiFetch } = useApi()
|
||||
|
||||
async function loadOwners() {
|
||||
loading.value = true
|
||||
error.value = ""
|
||||
|
||||
const result = await apiFetch("/owners")
|
||||
|
||||
if (isUnauthorized(result)) {
|
||||
loading.value = false
|
||||
return result
|
||||
}
|
||||
|
||||
owners.value = result
|
||||
loading.value = false
|
||||
return result
|
||||
}
|
||||
|
||||
return {
|
||||
owners,
|
||||
loading,
|
||||
error,
|
||||
loadOwners
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue