Updated
This commit is contained in:
@@ -9,22 +9,20 @@ const route = useRoute();
|
|||||||
const id = route.params.id as string | undefined;
|
const id = route.params.id as string | undefined;
|
||||||
const page = ref(1);
|
const page = ref(1);
|
||||||
|
|
||||||
const { suspense : suspenseProduct } = useGetProduct(id);
|
const { suspense: suspenseProduct } = useGetProduct(id);
|
||||||
const { suspense : suspenseComments} = useGetComments(id, page);
|
const { suspense: suspenseComments } = useGetComments(id, page);
|
||||||
|
|
||||||
// ssr
|
// ssr
|
||||||
|
|
||||||
await useAsyncData(async () => {
|
const productResponse = await suspenseProduct();
|
||||||
const productResponse = await suspenseProduct();
|
const commentsResponse = await suspenseComments();
|
||||||
const commentsResponse = await suspenseComments();
|
|
||||||
|
|
||||||
if (productResponse.isError || commentsResponse.isError) {
|
if (productResponse.isError || commentsResponse.isError) {
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
statusMessage: `error : product ${id} prefetch error`
|
statusMessage: `error : product ${id} prefetch error`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user