#Can you share what your product tsx
1 messages · Page 1 of 1 (latest)
Sure, here you go:
export default function Product() {
const router = useRouter()
const { urlSlug } = router.query
const rawProduct = useQuery(QUERY_PRODUCTS, {
variables: {
locale: router.locale,
urlSlug: urlSlug?.toString()
},
skip: !router.isReady
})
const product = rawProduct.data.products.attributes.data
return (
<div>
{product.name}
</div>
)
}
To get back to my problem: rawProduct.data is undefined
To help troubleshoot this lets add some error checking
const {
loading,
error,
data
} = useQuery(QUERY_PRODUCTS, {
variables: {
locale: router.locale,
urlSlug: urlSlug?.toString()
},
skip: !router.isReady
})
if (error) return `Error! ${error.message}`;
I'm still having the same Issue, I did some loading stuff too, to prevent the error is coming that way