Files
go_nuxt_admin/app/plugins/02.fetch_hero.ts
Beyhan Oğur 5285a0dd86 first commit
2026-04-26 22:07:47 +03:00

21 lines
506 B
TypeScript

import type { Hero } from "~~/types/hero";
export default defineNuxtPlugin(async () => {
const { useHeroStore } = await import('@/stores/hero')
const heroStore = useHeroStore()
const config = useRuntimeConfig();
const apiUrl = config.public.BASE_API_URL;
try {
const data = await $fetch<Hero>(`${apiUrl}/api/v1/hero`)
if (data) {
heroStore.setHero(data)
}
} catch (error) {
console.error('Failed to fetch settings:', error)
}
})