ContentRelationshipField Error

Hi all,
I'm having trouble getting a Linked Data.
Since it's using the default tsx, it keeps getting this error.
Type error: Property 'data' does not exist on type 'ContentRelationshipField<"category">'.
But I didn't find any official documentation on how to handle this process.

export default async function Page() {
    const client = createClient();
    const pageNumber = getPageNumber();

    const categories = await client.getByType('category')

    const posts = await client.getByType('blog', {
        orderings: {
            field: 'document.first_publication_date',
            direction: 'desc',
        },
        fetchLinks: ['category.uid', 'category.name'],
        pageSize: 10,
        page: pageNumber,
    })

return(
 {posts.results.map((post) => (
<article key={post.id} >
<Link href={`/blog/category/${post.data.category.data.uid}`}>
{post.data.category.data.name}
</Link>
</article>
);
}

Hello @cyberguard

Welcome to the Prismic community, and thanks for reaching out to us.

Here, metadata (UID) doesn't come under the data. It should be like this:
<Link href={/blog/category/${post.data.category.uid}}>.

You can check your API response. Here is a sample example of the API response of linked content:

"example_content_relationship": {
  "id": "X9C65hEAAEFIAuLo",
  "type": "blog",
  "tags": [],
  "slug": "another-page-title",
  "lang": "en-us",
  "uid": "my-blog",
  "data": {
    "author_name": "Jane Doe"
  },
  "link_type": "Document",
  "isBroken": false
}

Give this a try, and let me know if you need any further assistance.

Thanks,
Priyanka

Hi, thanks for the reply.
I found that the structure of the data I get is consistent with what you describe, but I can't get direct access to this part of the data.


I get the data data under category via fetchlinks, but I can't access the name attribute
{post.data.category.data.name}

Thanks your help