Search code examples
node.jsstrapiinsomnia

why Strapi dont fetch relationship in retrived data?


I created an API using strapi, and everything work fine until now. A have an "Event" and a "Stand" collection, I set up things in order to have multiple stands in event.

enter image description here

enter image description here

I use Insomnia to try the API and fetch the data, and when I fetch the events, I dont have any clue of the relations.

enter image description here

Everywhere people say relations should appears here, so, if you have any ideas, thank you.


Solution

  • Strapi won't retrieve by default the relations. You must specify in your API call that you want to retrieve everything including the relationships.

    For that, at the end of your GET request add : ?populate=*

    request: http://localhost:1337/api/events?populate=*

    You have more options here is you want to see deeper or not :

    https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/populating-fields.html#relation-media-fields