How to set limit on amount of files returned from media library

System Information
  • Strapi Version: 4.1.3
  • Operating System: Windows
  • Database: PostgreSQL
  • Node Version: v14.15.0
  • NPM Version: 6.14.8
  • Yarn Version: -

In strapi v3 when you did a request to the media library via route /api/upload/files you could limit the amount of entries returned with _limit=10 parameter, is there a way in v4 to limit the amount of entries returned since /api/upload/files route doesn’t have meta object with pagination and _limit doesn’t work

Here is an example query:

What you need is start and limit.

const firstPageAdd = this.pagination.page === 1 ? 0 : 1
const query = this.$qs.stringify(
     {
       _q: this.q,
       sort: this.sort,
       start:
         (this.pagination.page - 1) * this.pagination.pageSize + firstPageAdd,
       limit: this.pagination.pageSize,
     },
     {
       encodeValuesOnly: true,
     }
   )
const files = await this.$axios.$get(`api/upload/files?${query}`)
1 Like