System Information
- Strapi Version: v4
- Operating System: MacOs
- Database: Sql
- Node Version: 16
- NPM Version:
- Yarn Version:
Hi everyone,
I run into an issue with strapi v4. I want to create a controller for an entity that have a relation with the user, it’s set according to the user that made the request. However the code does not work
/**
* simulation controller
*/
const { createCoreController } = require('@strapi/strapi').factories;
module.exports = createCoreController('api::simulation.simulation', ({strapi}) => ({
async create(ctx) {
const user = ctx.state.user
ctx.request.body.data.user = {id: user.id}
const entity = await super.create(ctx);
return entity;
}
}));