System Information
- Strapi Version: 4.12.5
- Operating System: MacOS 14
- Database: Postgres
- Node Version: 18
- NPM Version: 9.6.4
- Yarn Version: 1.22.19
Hey, I want to create custom API returns pagination data which look like this:
When I investigate strapi’s source, I found that we can extends core controller like this:
async find(ctx) {
let { query } = ctx;
query.offset = query.offset ?? 0;
query.limit = query.limit ?? 20;
const entity = await strapi.entityService.findMany("api::test.test", query);
const sanitizedEntity = await this.sanitizeOutput(entity, ctx);
let { data, meta } = this.transformResponse(sanitizedEntity);
return {
data,
meta: {
total: await strapi.db.query("api::test.test").count(query),
offset: query.offset,
limit: query.limit,
},
};
},
But how can I use transformResponse
and sanitizeOutput
function without createCoreController
?