Skip to content

Commit ddb79ab

Browse files
authored
Switch Carousel to useAsyncData (#180)
1 parent 82e6ab1 commit ddb79ab

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

components/Block/Carousel/Carousel.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,16 @@ import CarouselDots from '~/components/Carousel/CarouselDots.vue';
55
import ClassNames from 'embla-carousel-class-names';
66
77
const { $directus, $readItem } = useNuxtApp();
8+
89
const props = defineProps<{ uuid: string }>();
9-
const block = ref<{ cards: Array<{ block_carousel_cards_id: string }> } | null>(null);
1010
11-
const fetchSlides = async () => {
12-
const result = await $directus.request(
11+
const { data: block } = useAsyncData(`carousel-${props.uuid}`, () =>
12+
$directus.request(
1313
$readItem('block_carousel', props.uuid, {
1414
fields: ['id', { cards: ['block_carousel_cards_id'] }],
1515
}),
16-
);
17-
18-
block.value = result as { cards: Array<{ block_carousel_cards_id: string }> };
19-
};
20-
21-
onMounted(async () => {
22-
await fetchSlides();
23-
});
16+
),
17+
);
2418
</script>
2519

2620
<template>

0 commit comments

Comments
 (0)