Skip to content

Commit 4eaa241

Browse files
committed
Use SSR async data for initial commits load
1 parent d61335f commit 4eaa241

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

packages/app/app/components/Commits.vue

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,22 @@ const props = defineProps<{
1212
repo: string;
1313
}>();
1414
15-
const data = await $fetch("/api/repo/commits", {
16-
query: {
17-
owner: props.owner,
18-
repo: props.repo,
19-
},
20-
});
15+
const { data } = await useAsyncData(
16+
`repo-commits:${props.owner}:${props.repo}:page:1`,
17+
() =>
18+
$fetch("/api/repo/commits", {
19+
query: {
20+
owner: props.owner,
21+
repo: props.repo,
22+
},
23+
}),
24+
);
2125
22-
if (!data) {
26+
if (!data.value) {
2327
throw createError("Could not load Commits");
2428
}
2529
26-
const branch = shallowReactive(data);
30+
const branch = shallowReactive(data.value);
2731
2832
const commitsWithRelease = computed(() =>
2933
branch.target.history.nodes

0 commit comments

Comments
 (0)