How to populate the meta object in custom controller?

Hi all,

I have created a custom route with a custom controller behind it using strapi.entityService.findMany() method.

In the response I get I do not have the meta object with the pagination details populated. It is empty.

Also tried with strapi.db.query().findMany() but same issue.

How can I have data in the meta object in my response from my custom controller?

Thanks in advance.

1 Like

Hi, here is an example from Strapi blog post:

// ./src/api/order/controllers/order.js
    module.exports = createCoreController('api::order.order', ({strapi}) => ({
      confirmOrder: async (ctx, next) => {
        ctx.body = "ok"
      find: async (ctx, next) => {
        // destructure to get `data` and `meta` which strapi returns by default
        const {data, meta} = await super.find(ctx)
        // perform any other custom action
        return {data, meta}