Strapi CMS third level populating
Asked Answered
S

4

7

I have a problem with fetching third level data from Strapi CMS.

My Structure is the following:

Page > Content(Dynamic Zone) > Multiple Entitys e.g. HeroSliderElement.

So Calling this URL from Postman:

{{protocol}}://{{host}}:{{port}}/api/pages?populate[Content][populate]=*

But since inside my HeroSliderElement are images i have the problem, that i dont get these back.

Request Detail There should be the media data linked from the CMS:

enter image description here

Does anyone have an Idea how to fix this? Any help is appreciated!

I am currently using the following versions of packages:

  "dependencies": {
"@strapi/plugin-i18n": "4.0.7",
"@strapi/plugin-users-permissions": "4.0.7",
"@strapi/provider-upload-aws-s3": "^4.1.0",
"@strapi/strapi": "4.0.7",
"pg": "8.6.0",
"strapi-provider-upload-aws-s3": "^3.6.8"

},

Sauveur answered 26/3, 2022 at 8:46 Comment(0)
C
11

Install the official strapi plugin : strapi-plugin-populate-deep , its easy and great plugin for nested content structure, it worked for me.

Examples: Populate a request with the default max depth.

/api/articles?populate=deep

Populate a request with the a custom depth

/api/articles?populate=deep,10

Populate a request with the a custom depth

/api/articles/1?populate=deep,10
Corriecorriedale answered 8/7, 2022 at 5:38 Comment(4)
Whilst this plugin is great for ease of use, when building applications at scale, you don't want to be creating queries that simply grab everything. Also, you're likely to pull down something you don't want the public to see. In other words, please use it with caution.Estimate
Yes, that comes with caution! So whoever is gonna use it please use it wisely. Thanks for your valuable advice. @DallasClarkCorriecorriedale
Jesus christ you saved me so much time!Weeny
Just want to add context to anyone using populate deep plugin. Since it get all the data for the depth specified. It may lead to performance issues. I no longer use the plugin and handle filtering and populating natively to Strapi. Here is a post that covers this process for any one who finds in confusing. strapi.io/blog/demystifying-strapi-s-populate-and-filteringAriew
W
2

In case you're still looking for a solution, refer to answer here - Strapi V4 populate dynamic zones media not populating

Wanderlust answered 13/4, 2022 at 22:55 Comment(1)
this helped me a lot thanks! Forgot to answer you :-)Sauveur
A
0

you need to specify every record(object, entity) at level three to fetch data from it. like as you said you want to fetch data of images from content from your this will work

{{protocol}}://{{host}}:{{port}}/api/pages?populate[Content][populate]=images

Amalita answered 31/3, 2022 at 12:55 Comment(4)
thank you for you answer. Unfortunately this does not fix my problem. The Content element is my "Zone" and one of the elements is the HeroSliderElement. And inside of the HeroSliderElement is Media. So I need to specify that the backend should return the media inside the HeroSliderElement inside the Content Zone inside the page. Do you have any idea? It would be awesome.Sauveur
Did you end up having any luck with this? I'm facing the issue.Wanderlust
nope @RodrigoRubio . perhaps we should open an issue.Sauveur
@Sauveur found a work around for now, hope it helps - #71845872Wanderlust
S
0

You can use this awesome plugin, it works like a charm strapi-plugin-populate-deep

Sis answered 16/1, 2024 at 19:50 Comment(1)
This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From ReviewSolarium

© 2022 - 2025 — McMap. All rights reserved.