first commit
This commit is contained in:
20
app/plugins/02.fetch_hero.ts
Normal file
20
app/plugins/02.fetch_hero.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
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)
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user