Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Strapi: what is best way to combine multiply Collections in one endpoint?

Tags:

strapi

lets imagine that we have 2 independent data collections:

  1. menu (contains labels + links [])
  2. posts (contains text [])

By default Strapi gives me 2 endpoints, one for menu and another for posts. That's fine, but how I can combine this two (or even 10+ small data collections) in one Strapi REST API response?

I'm new to Strapi so need most simple and effective solution. I know that possible to make a custom endpoint but in this case I should manually add/remove any collections inside Strapi config - think its not a true way.

Thank you for your time!


1 Answers

You can also create another collection e.g. agg_collection that has relations to both collections so you can retrieve them by calling api/agg_collection?populate=....

Writing a custom endpoint is the preferred solution I suppose, but the question is; do you really need to have it in a single request?

like image 163
Sjouke Avatar answered Jan 21 '26 09:01

Sjouke



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!