0

In the example on the site

Strapi Docs

To populate specific relations, one or several levels deep, use the LHS bracket notation for fields names in combination with the populate parameter. The qs library (opens new window)is helpful to build complex URLs:

const qs = require('qs');
const query = qs.stringify({
  populate: {
    author: {
      populate: ['company'],
    }
  } 
}, {
  encodeValuesOnly: true,
});

await request(`/api/articles?${query}`);
// GET /api/articles?populate[author][populate][0]=company

How to fill relationships, two three or more several levels deep?

In my example, I tried

/api/regions?populate[cities][populate][0]=holding?spopulate[companies][populate][0]=holdings
Alexsey
  • 31
  • 5
  • const qs = require('qs'); const query = qs.stringify({ populate: { author: { populate: { ['company'], } } }, { encodeValuesOnly: true, }); await request(`/api/articles?${query}`); – Bilal Khursheed Mar 31 '22 at 12:58

1 Answers1

0

The answer to this question was posted here. Make sure you're using Strapi v4 and simply install the plugin to the Strapi server.

paq
  • 87
  • 8