Get comments on ssr
This commit is contained in:
@@ -2,23 +2,27 @@
|
|||||||
|
|
||||||
import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
import ChatButton from "~/components/product/ChatBox/ChatButton.vue";
|
||||||
import useGetProduct from "~/composables/api/product/useGetProduct";
|
import useGetProduct from "~/composables/api/product/useGetProduct";
|
||||||
|
import useGetComments from "~/composables/api/product/useGetComments";
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
|
||||||
const id = route.params.id as string | undefined;
|
const id = route.params.id as string | undefined;
|
||||||
|
const page = ref(1);
|
||||||
|
|
||||||
const { suspense } = useGetProduct(id);
|
const { suspense : suspenseProduct } = useGetProduct(id);
|
||||||
|
const { suspense : suspenseComments} = useGetComments(id, page);
|
||||||
|
|
||||||
// ssr
|
// ssr
|
||||||
|
|
||||||
await useAsyncData(async () => {
|
await useAsyncData(async () => {
|
||||||
const response = await suspense();
|
const productResponse = await suspenseProduct();
|
||||||
|
const commentsResponse = await suspenseComments();
|
||||||
|
|
||||||
if (response.isError) {
|
if (productResponse.isError || commentsResponse.isError) {
|
||||||
throw createError({
|
throw createError({
|
||||||
statusCode: 404,
|
statusCode: 404,
|
||||||
statusMessage: `error : ${response.error.message}`,
|
statusMessage: `error : product ${id} prefetch error`
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -30,7 +34,7 @@ await useAsyncData(async () => {
|
|||||||
<ProductVideo />
|
<ProductVideo />
|
||||||
<ProductComments />
|
<ProductComments />
|
||||||
<ProductDetails />
|
<ProductDetails />
|
||||||
<!-- <ProductsSlider title="محصولات مشابه" />-->
|
<!-- <ProductsSlider title="محصولات مشابه" />-->
|
||||||
<ChatButton />
|
<ChatButton />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
Reference in New Issue
Block a user