Contentful logo

Contentful Community

How to list entry's linked fields

Hi. I’m a little confused about how to retrieve a list of all the linked fields in an entry.
For example, I have a content type of landingPage that contains a field called sections which is a link to many content types.
I want to retrieve a list of how many linked entries ‘sections’ had.

I followed these instructions from the guide which I thought was my case but it’s not working:

Links to a specific item
If you want to retrieve all items linked to a specific entry, the query URL should filter entries on their specific content_type , linking_field (field to link items) and entry_id from the target entry.

My query:

const entries = await client.getEntries({
    content_type: 'landingPage',
       'fields.sections.sys.id': '2MdUQKIq7mqqguMaKsSkoE',
        include: 5
     })

In this specific entry I have 3 sections but I get a response with the total:0 . What am I doing wrong?

Hi Gisete,

Are you trying to retrieve the actual content of these linked items or simply the number amount of items that were referenced in that field?

Hi @gabriel, I’m trying to retrieve the content of the linked items.