Skip to content

Commit

Permalink
Fix useAsyncData call
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed Apr 13, 2024
1 parent fe621b8 commit 3dc1c23
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions print/components/story/StoryPeriod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,30 @@ const props = defineProps({
const { $api } = useNuxtApp()
const { data, error } = await useAsyncData('StoryPeriod', async () => {
const contentTypeStorycontext = (
await $api.get().contentTypes().$loadItems()
).items.find((contentType) => contentType.name === 'Storycontext')
const { data, error } = await useAsyncData(
`StoryPeriod-${props.period._meta.self}`,
async () => {
const contentTypeStorycontext = (
await $api.get().contentTypes().$loadItems()
).items.find((contentType) => contentType.name === 'Storycontext')
const [periodStoryChapters] = await Promise.all([
$api
.get()
.contentNodes({
period: props.period._meta.self,
contentType: contentTypeStorycontext._meta.self,
})
.$loadItems(),
props.period.days().$loadItems(),
props.period.scheduleEntries().$loadItems(),
props.period.camp().categories().$loadItems(),
])
const [periodStoryChapters] = await Promise.all([
$api
.get()
.contentNodes({
period: props.period._meta.self,
contentType: contentTypeStorycontext._meta.self,
})
.$loadItems(),
props.period.days().$loadItems(),
props.period.scheduleEntries().$loadItems(),
props.period.camp().categories().$loadItems(),
])
return {
days: props.period.days().items,
periodStoryChapters: periodStoryChapters.items,
return {
days: props.period.days().items,
periodStoryChapters: periodStoryChapters.items,
}
}
})
)
</script>

0 comments on commit 3dc1c23

Please sign in to comment.