System Information
-
Strapi Version:
4.8.2 -
Operating System:
Linux Manjaro -
Database:
sqlite -
Node Version:
16.18.1 -
NPM Version:
8.19.2
Hi there!
I’m struggling creating a core router for a content-type created in a strapi plugin. I did the following (according to the docs):
// src/plugins/pluginname/server/controllers/foo.js
const { createCoreController } = require("@strapi/strapi").factories;
module.exports = createCoreController("plugin::pluginname.foo", ({ strapi }) => ({
async find(ctx) {
// This is called
console.log('find() called');
// This fails
const { data, meta } = await super.find(ctx);
return { data, meta };
},
}));
//src/plugins/pluginname/server/routes/foo.js
module.exports = {
type: 'admin',
routes: [
{
method: 'GET',
path: '/plugin/foo/find',
handler: 'foo.find',
config: {
policies: [],
auth: false,
prefix: ""
},
}
],
};
When I’m calling the http://localhost:1337/plugin/foo/find
route, the console logs the message. However the super
call fails. I’m quite sure that I’m calling the correct content-type (plugin::pluginname.foo
), since when I change this to e.g. plugin::pluginname.bar
the server won’t even start.
Help is really very much wanted - thank you a lot!
PS: I also can’t create a createCoreRoutes
, this causes the server to shutdown, prompting “cannot read properties of undefined (reading ‘kind’)”.