Reputation: 53
I have created a component with a media field. When I upload an image/video I can’t see it in the API. I’ve even tried using ?populate=*
.
What can I be missing?
Upvotes: 2
Views: 1758
Reputation: 11
Check this discussion https://github.com/strapi/strapi/issues/11836
Now go here https://www.npmjs.com/package/strapi-plugin-populate-deep
For NPM:
npm install strapi-plugin-populate-deep
For Yarn:
yarn add strapi-plugin-populate-deep
Now use it like this:
/api/<name>?populate=deep
Upvotes: 0
Reputation: 1934
The populate=*
give’s you the first level of relations so you get only component, but not the relation included in component.
I’m not sure what is your model looks like, what would give some more info how to properly write query, you have two options:
The easiest solution is:
yarn add strapi-plugin-populate-deep
/api/pages/1?populate=deep
harder one is to use qs
with something like:
const str = qs.stringify(
{
populate: { hero: { populate: ["media", "heroImage"] } }
},
{ encodeValuesOnly: true }
);
witch would give you:
populate[hero][populate][0]=media&populate[hero][populate][1]=heroImage
Upvotes: 3