feat(footer): create footer with backend-provided metadata
This commit is contained in:
29
src/composables/useMeta.ts
Normal file
29
src/composables/useMeta.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { onMounted, ref } from 'vue';
|
||||
import type { components } from '../api/schema';
|
||||
import { apiClient } from '../api/client';
|
||||
|
||||
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 };
|
||||
}
|
||||
Reference in New Issue
Block a user