System Information
- Strapi Version: “@strapi/strapi”: “^4.3.2”,
- Operating System: MacOS 12.5
- Database: Mysql 8.0
- Node Version: 14.20.0
- NPM Version: 8.1.0
- Yarn Version: 1.22.19
Followed the docs, Strapi Internals: Customizing the Backend, in order to customize existing controllers, I used the following codes copied from the page,
// ./src/api/order/controllers/order.js
...
module.exports = createCoreController('api::order.order', ({strapi}) => ({
confirmOrder: async (ctx, next) => {
ctx.body = "ok"
},
find: async (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}
}
}));
but this cause my strapi server crashed, logs are:
yarn run v1.22.19
$ strapi develop
[2022-08-02 13:07:02.821] debug: ⛔️ Server wasn't able to start properly.
[2022-08-02 13:07:02.822] error: 'super' keyword unexpected here
/Users/crosszheng/CODES/Strapi/demo/my-project-mysql/src/api/book/controllers/book.js:16
const {data, meta} = await super.find(ctx)
^^^^^
SyntaxError: 'super' keyword unexpected here
at compileFunction (<anonymous>)
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at importDefault (/Users/crosszheng/CODES/Strapi/demo/my-project-mysql/node_modules/@strapi/strapi/lib/utils/import-default.js:6:17)
at loadFile (/Users/crosszheng/CODES/Strapi/demo/my-project-mysql/node_modules/@strapi/strapi/lib/core/loaders/apis.js:158:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.