Skip to content

Commit

Permalink
Switch Carousel to useAsyncData (#180)
Browse files Browse the repository at this point in the history
  • Loading branch information
LZylstra authored Jan 15, 2025
1 parent 82e6ab1 commit ddb79ab
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions components/Block/Carousel/Carousel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,16 @@ import CarouselDots from '~/components/Carousel/CarouselDots.vue';
import ClassNames from 'embla-carousel-class-names';
const { $directus, $readItem } = useNuxtApp();
const props = defineProps<{ uuid: string }>();
const block = ref<{ cards: Array<{ block_carousel_cards_id: string }> } | null>(null);
const fetchSlides = async () => {
const result = await $directus.request(
const { data: block } = useAsyncData(`carousel-${props.uuid}`, () =>
$directus.request(
$readItem('block_carousel', props.uuid, {
fields: ['id', { cards: ['block_carousel_cards_id'] }],
}),
);
block.value = result as { cards: Array<{ block_carousel_cards_id: string }> };
};
onMounted(async () => {
await fetchSlides();
});
),
);
</script>

<template>
Expand Down

0 comments on commit ddb79ab

Please sign in to comment.