Prefetch product data on ssrz
This commit is contained in:
@@ -1,5 +1,25 @@
|
||||
<script lang="ts" setup>
|
||||
|
||||
import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
||||
import useGetProduct from "~/composables/api/product/useGetProduct";
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
const id = route.params.id as string | undefined;
|
||||
|
||||
const { suspense } = useGetProduct(id);
|
||||
|
||||
onServerPrefetch(async () => {
|
||||
const response = await suspense();
|
||||
|
||||
if (response.isError) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: `error : ${response.error.message}`,
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -8,7 +28,7 @@ import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
||||
<ProductVideo />
|
||||
<ProductComments />
|
||||
<ProductDetails />
|
||||
<RelatedProducts title="محصولات مشابه" />
|
||||
<ProductsSlider title="محصولات مشابه" />
|
||||
<ChatButton />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user