Rendxn
Rendxn

Reputation: 75

Is there a way to populate nested relations in Strapi?

Already had a look at this other question, but it didn't seem to work for me.

Problem

So in the video (referenced below) at 9:58, he gets the Menu but the Section DOES NOT HAVE LINKS. Is there a way to populate them from the Menu?

Where it comes from

I was watching this video from Strapi on Youtube in which he creates a Menu. The Menu has the following components:

Also, a Dropdown has a one-to-many relation with Section, which contains multiple Link components.

Something like this:

Menu schema

Thanks.

Upvotes: 0

Views: 8448

Answers (2)

JustinoSE
JustinoSE

Reputation: 1

You can grab a list or an object along with its fields related to other objects or lists.

Example, imagine the following structure:

Events { Title Desc Organizer { Name, Photo } }

http://yourserver/api/events?populate[Organizer][populate][0]=Photo

You will return the list of events with your organizers and inside each organizer you will have the Photo included. You can populate as many relationships or media fields as the api allows.

More Here: https://docs.strapi.io/dev-docs/api/rest/guides/understanding-populate#populate-several-levels-deep-for-specific-relations

Upvotes: 0

Tom
Tom

Reputation: 369

You will have to build a custom controller in order to populate nested relations in strapi.

Only solution that I found working is this.

Upvotes: 1

Related Questions