'Strapi : populate from a relation
In the example on the site
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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
