mingxi
1
Hello Guys,
I have a easy question. 
For example: I have a ContentType called “cat”:
module.exports = createCoreController('api::cat.cat', ({ strapi }) => ({
...
const res = await super.find();
...
};
How do I call “find()” in “cat” from another controller like:
module.exports = createCoreController('api::dog.dog', ({ strapi }) => ({
...
// I want to find some cats... :);
...
};
Thanks in advance!
mingxi
3
I can find the answer to my first question myself, but I still have another question.
e.g.:
module.exports = createCoreController('api::cat.cat', ({ strapi }) => ({
...
// Method 1: Creating an entirely custom action
async exampleAction(ctx) {
try {
ctx.body = 'ok';
} catch (err) {
ctx.body = err;
}
},
};
How do I call “exampleAction(ctx)” in “cat” from “dog” controller?
module.exports = createCoreController('api::dog.dog', ({ strapi }) => ({
...
// How do I call “exampleAction(ctx)” in “cat” from "dog"?
...
};
strapi.controllers["api::cat.cat"].exampleAction
1 Like
mingxi
5
Many thanks for the quick response!
