Big issue when fetching nested components in a collection type

Hello everybody,

I’ve created a component entitled “Deroulant-Navbar” who’s calling himself the component “Lien-Navbar”.

In my collection type “Barre-de-navigation”, I’ve created a entry with title “titre” and a Deroulant-Navbar who contains a element “Lien-Navbar” entitled “TEEEEEEEEST”.

Screenshot here :

When I fetch by this way : http://localhost:1337/api/navigations/8?populate=*

I have the following answer :

{
“data”:{
“id”:8,
“attributes”:{
“createdAt”:“2023-10-27T10:05:03.371Z”,
“updatedAt”:“2023-10-27T10:21:45.869Z”,
“publishedAt”:“2023-10-27T10:05:04.789Z”,
“titre”:“Mon Onglet”,
“lien_navbar”:[
{
“id”:3,
“__component”:“composants.deroulant-navbar”,
“titre_du_menu”:“Titre du menu”
}
]
}
},
“meta”:{

}
}

As you can see, in my reponse, I have my “__component”:“composants.deroulant-navbar” but i don’t have my “TEEEEEEEEST” sub-component… how can I access to all sub-components for my main component “deroulant-navbar” ?

Thanks a lot !

Help would be much appreciated :anguished:

This article explains it.

Also if you don’t want to write it by hand

will help you there if you enable auto-populate in its config

1 Like

Hello Boegie19, thanks you for your answer :slight_smile:

I followed the steps of your second link (Protected Populate | Strapi Market) but this plugin was made to protect the data more than to get full access to nested data ( like components containing anothers components, in my case ), so it’s not why I’m searching for… i’m searching for the opposite :smiley:

Is there a plugin to achieve the task I want to accomplish ?

For your second link, Demystifying Strapi's Populated & Filtering, I tried many types of requests inspired by the exemples but I didn’t found a single one that works…

For exemple, with the following request, I can’t get components ( text blocs ) inside my “supercontainer” :

http://localhost:1337/api/pages/8?populate=*

I have only this response :

{
   "data":{
      "id":8,
      "attributes":{
         "createdAt":"2023-10-27T18:47:33.107Z",
         "updatedAt":"2023-10-28T16:29:15.643Z",
         "publishedAt":"2023-10-27T18:48:10.195Z",
         "nom_de_page":"accueil",
         "Composants":[
            {
               "id":6,
               "__component":"composants.titre",
               "titre":"Accueil du site",
               "taille":"h3",
               "position":"centre"
            },
            {
               "id":2,
               "__component":"composants.supercontainer"
            }
         ]
      }
   },
   "meta":{
      
   }
}

As you can see, in this case, I have only

"__component":"composants.supercontainer"

and not the text bloc inside…

How can I get the nested data in this situation ?

Here is the struct of my supercontainer :

Thanks again :slight_smile:

Protected Populate | Strapi Market)
Does both tasks if you in the config set auto-populate to true. and don’t populate at all. aka http://localhost:1337/api/pages/8

Only goos 1 layer deep relation wise that is why you need to populate multiple layers deep manually.

You can do this by hand like they show in the article.
Use protected populate to have full control over what you want to populate with (auto-populate=true)

or a 3rd option is GitHub - Barelydead/strapi-plugin-populate-deep: A Strapi plugin that makes it easier to populate deep content structures Note that this will lead to performance issues in production since it populates a lot more invisible things you can’t see.

1 Like

WOAW WOAW WOAW !
With only the http://localhost:1337/api/pages/8 url I have MY NESTED DATA after 2 days of struggling ! :smiley:

I just saw that you are the developer of this plugin, I don’t know how to be thankful, you litteraly saved me and my important project ( I have to present my final project in front of a jury ), it 100% works now, you’re the best my bro.

10000000000000000000000000000000000000000X thanks Boegie19 !!! :star_struck: :star_struck: :star_struck:

There isn’t pertinent video about this issue on YouTube, I’ll make a tutorial video in the next days to show how to achieve the fetching of nested data within your plugin, I’ll credit you !

1 Like

It is explained on youtube but the manual process and not with my plugin if you want to make a video about it I would be happy I will even link it in the marketplace and github.

1 Like