Files
sta/src/composables/useMeta.ts

31 lines
788 B
TypeScript
Raw Normal View History

import { onMounted, ref } from 'vue';
2026-05-15 10:01:36 +02:00
import { apiClient } from '../api/client';
2026-05-15 10:01:36 +02:00
import type { components } from '../api/schema';
type Meta = components['schemas']['Meta'];
export function useMeta() {
const isLoading = ref(false);
const metadata = ref<Meta | null>(null);
const error = ref<string | null>(null);
const getMetadata = async () => {
isLoading.value = true;
try {
const { data } = await apiClient.GET('/api/meta');
error.value = null;
metadata.value = data as Meta;
} catch (err: any) {
console.error('Failed to fetch metadata:', err);
error.value = err.message || 'Failed to fetch metadata';
} finally {
isLoading.value = false;
}
};
onMounted(getMetadata);
return { isLoading, metadata, error };
}