21 lines
525 B
TypeScript
21 lines
525 B
TypeScript
import type { Banner } from "~~/types/banner";
|
|
|
|
export default defineNuxtPlugin(async () => {
|
|
|
|
|
|
const { useBannerStore } = await import('@/stores/banner')
|
|
const bannerStore = useBannerStore()
|
|
|
|
const config = useRuntimeConfig();
|
|
const apiUrl = config.public.BASE_API_URL;
|
|
|
|
try {
|
|
const data = await $fetch<Banner[]>(`${apiUrl}/api/v1/hero`)
|
|
if (data) {
|
|
bannerStore.setBanner(data)
|
|
}
|
|
} catch (error) {
|
|
console.error('Failed to fetch banners:', error)
|
|
}
|
|
})
|