Strapi Populate not working

Hi all - I am struggling to find a solution for my API data. My design is that “Albums” have a one-to-many relationship with “songs”. In general, an Album can have many songs, but a song can be part of one Album only.

http://localhost:1337/api/albums?populate=* - gives me all Album data (incl. Album cover image etc) but song does not have data for song file, song image etc

http://localhost:1337/api/albums?populate[songs][populate]=* - gives me all the song data (like song file, cover image etc) but the Album does not show data like Album cover image etc

I am not able to display all the Album data and the Song data in one api. Can someone please help me?

Thanks
J

5 Likes

After breaking my head, and pulling my hair, I was finally able to find a solution. I hate to say this, but making the API complex is such a foolish strategy. If the team is worried about performance, then they should allow for options and not completely disable it.

The solution.

  1. Install strapi-plugin-populate-deep - npm
  2. Build your admin
  3. Use /posts?populate=deep to get up to 5 levels deep of data. You can customize up to 10

Strapi, you have to strategize better, not get on the nerves of your users. A headless CMS should ideally simplify things, not complicate them.

Best of luck guys!

12 Likes

This was really helpful, THANK YOU! :fire:

2 Likes

How to customize it?

I am also stuck as like you. I’ve item table which brings it’s details from item_detail table and item_dimensions table. but item_detail table have relation with item_offers table and item_dimensions table relation with unit table. which are not fetching while populate the item table can you give idea about how to customise it?

:smiling_face_with_three_hearts:Thank you mate for your help

Tried this but it did not help in my case where I have to populate a reference to a same collection type object. Got Your filters contain a field 'populate' that doesn't appear on your model definition nor its relations error every time I tried.