System Information
- Strapi Version: 4.20.5
- Operating System: macos
- Database: postgres
- Node Version: 18.17.1
- NPM Version: 9.6.7
- Yarn Version: not used
Hi, I am trying to extend service, I have read those articles:
I have a collection type named ‘persona’ and after trials and errors I came up with this code:
const { createCoreService } = require('@strapi/strapi').factories;
console.log('XXX')
let xxx = ({ strapi }) => {
console.log('YYY');
return ({
async find(...args) {
console.log('ZZZ');
// Calling the default core controller
const {results, pagination} = await super.find(...args);
return {results, pagination};
},
async findOne(entityId, params) {
// some logic here
console.log('AAA');
const result = await super.findOne(entityId, params);
// some more logic
return result;
}
});
};
export default createCoreService('api::persona.persona', xxx);
This code is placed in src/api/persona/services/persona.ts
where the default code generated by Strapi was placed. In logs I can see XXX
phrase during strapi startup, but no YYY
, ZZZ
nor AAA
when clicking in a browser on the persona list or on the single persona. Therefore I assume that the file is processed but neither find
nor findOne
is overriden.
My question is: what is wrong in my code that it does not override the service properly?