Issue with Rest and Populate on a Media Field in Strapi

System Information
  • Strapi Version:
  • Operating System:
  • Database:
  • Node Version:
  • NPM Version:
  • Yarn Version:

I have a media field in Strapi that contains seven images, but I only want to retrieve the first two images using Rest and Populate. Currently, I’m able to retrieve all seven images in an array, but I only need the first two.

Here’s an example of my current query using qs.stringify:

const PopulaireDataQuery = qs.stringify(
  {
    populate: {
      Images: {
        fields: ['url', 'formats'],
      },
    },
  },
  {
    encodeValuesOnly: true,
  }
);

Can anyone suggest how I can modify this query to retrieve only the first two images using Rest and Populate?

Any help or guidance would be greatly appreciated. Thank you!

You can use filters to only get the 2 you need

@purple_pillow did you found a solution to your issue? I don’t see how @Boegie19 is solving it.

Given I have an article API, with a “cover” media file, and I only want to populate the large format. How can it be done?

This doesn’t seem to work (I get all formats):

{
  populate: {
    cover: {
     populate : {
     formats:{
        populate: {
          large: true
        }
      }
     } 
    }
  }
}