How to fetch multiple collections in a single request?

Hi everyone :waving_hand:

I’m currently using the JavaScript SDK like this to fetch multiple collections:

await Promise.all([
  directus.request(readItems('collection1', { fields: ['*'] })),
  directus.request(readItems('collection2', { fields: ['*'] })),
  directus.request(readItems('collection3', { fields: ['*'] })),
]);

It works, but I don’t really like this approach
Is there a better or more efficient way to fetch data from multiple collections in a single request?

Unfortunately not with REST API as it needs to hit an endpoint per collection.

You could either

  1. make a custom endpoint with an extension which would query all resources from database and return them at once or

  2. use graphql to query the data