Super.find() to override an existing controller failed

What I see is that by using the arrow function we are breaking the scope so we can use the super keyword. We could solve it in the following way:

'use strict';

/**
 *  order controller
 */

const { createCoreController } = require('@strapi/strapi').factories;

module.exports = createCoreController('api::order.order', ({ strapi }) => ({
  async confirmOrder (ctx, next) {
    ctx.body = 'ok';
  },
  async find (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}
  }
}));
3 Likes