No video

Customizing Strapi: Creating Controllers

  Рет қаралды 20,039

Strapi

Strapi

Күн бұрын

Description:
In this video, we show you how you can create three different types of actions on a custom controller in Strapi. First, we create a completely custom action, second, we override an action using built-in functionality, and finally, we override an action using more custom functionality. Creating different types of actions on a controller allows you to fully customize the CRUD operations offered out of the box by Strapi.
Chapters:
0:19 - CMS Collection Setup
2:50 - Create Custom Controller Action
4:42 - Create Custom Route
6:33 - Wrap Existing Controller Action
9:19 - Advanced Override of Controller Action
---
Follow the Quick Start Guide: docs.strapi.io....
Try live demo: strapi.io/demo
Strapi Blog: strapi.io/blog
Find help in our Forum: forum.strapi.io/
We are hiring! strapi.io/careers

Пікірлер: 19
@unoleeone
@unoleeone 2 жыл бұрын
Great, also expecting Custom GraphQL, please
@cristianocolangelo9920
@cristianocolangelo9920 2 жыл бұрын
Would be cool to get some more content on how to extend GraphQL endpoints
@dmitryzhuravlev-nevsky1388
@dmitryzhuravlev-nevsky1388 Жыл бұрын
Thank you. It doesn't seem as a brand new Strapi setup tho. The GET /api/todos responses with 403 Forbidden. Can you clarify this step, please?
@moneyfr
@moneyfr 2 жыл бұрын
Sound too low
@ezequielviera7048
@ezequielviera7048 9 ай бұрын
Does this solution still work? because I tried to follow the steps and when I try to access the ctx.body (as well as its parameters) I get this error: "The property 'body' does not exist in type 'unknown'.ts(2339)". my project is js, but maybe from the year in which this video was published to the current date there have been changes.
@Strapi
@Strapi 9 ай бұрын
Can you share a code snippet or example? Here is another example of a plugin I was working on where I created custom controllers github.com/PaulBratslavsky/strapi-plugin-open-ai-embeddings/blob/main/server/controllers/open-ai-embeddings.js. that call custom service. We also have an open office house Monday - Friday at 12:30 PM CST if you want to stop by and share your example. discord.com/invite/strapi
@ezequielviera7048
@ezequielviera7048 8 ай бұрын
@@Strapi Of course, thanks for replying and sharing an example. in my consultation.js controller I have the following code: 'use strict'; const { createCoreController } = require('@strapi/strapi').factories; module.exports = createCoreController('api::consultation.consultation', ({ strapi }) => ({ async exampleAction(ctx) { try { ctx.request.body; // Property 'body' does not exist in type 'Request'.ts(2339) any ctx.body.exampleParameter; //Property 'exampleParameter' does not exist in type 'unknown'.ts(2339) any } catch (err) { ctx.body = err; } } })); I've tried several ways but I get the error you see commented out, that it can't access properties of an unknown type. To try to solve this problem, and as I had already created custom endpoints in extensions/users-permissions/strapi-server.js, I decided to develop my endpoint there. Certainly I think it is not the right place, but adding it to the pulgin did not bring me these inconveniences: plugin.controllers.user.exampleAction= async (ctx) => { try { ctx.request.body; // no problems ctx.request.body.exampleParameter; // no problems } catch (err) { ctx.response.body = err; } }
@soutrikbanerjee8243
@soutrikbanerjee8243 5 ай бұрын
i was trying to get the parameter by const { query }=ctx.params and then strapi.query('api::partner.partner').findMany({ query }) it is not working when i tried to console.log i got undefined
@ArtOfFun
@ArtOfFun 2 жыл бұрын
Thank you for this tutorial. That's what I was looking for!
@user-zw6ff2us5l
@user-zw6ff2us5l Жыл бұрын
I want create custom routes and controller without content type in Typescript so please provide the details.
@jhon73120
@jhon73120 Жыл бұрын
please, update your documentation in the website, do some more examples
@jsricochet
@jsricochet Жыл бұрын
Clear and to the point. Thanks :)
@--VICKY-
@--VICKY- Жыл бұрын
is there any way to get data from api by filtering data present in components?
@nicom2009
@nicom2009 Жыл бұрын
Thanks
@jsricochet
@jsricochet Жыл бұрын
Thank to your video, I was able to create a custom action to list all the options of an enum named 'originality'. It works fine. But I was wondering if this Is the recommended way to do so or if there is an easier way to list all possible values of an enum belonging to a model (here, the 'idea' model)? My aim is to populate a drop list used by a React client without having to hard code the options clientside so that if an extra option is added, it is reflected clientside. async getOriginality(ctx) { const model = strapi.getModel("api::idea.idea"); const originality = model.attributes.originality.enum; return { originality }; },
@edwardalmanzar8382
@edwardalmanzar8382 2 жыл бұрын
👍
@khaledsanny4817
@khaledsanny4817 Жыл бұрын
Who are you talking to ? The content itself is great ...but its so difficult to hear you ...its not cool.... adress that plz
Strapi Lifecycle Hooks: Theory and Practice
49:14
Artcoded //by Jib
Рет қаралды 4,4 М.
Strapi v4 Crash Course
1:25:29
Laith Academy
Рет қаралды 151 М.
What will he say ? 😱 #smarthome #cleaning #homecleaning #gadgets
01:00
The Joker kisses Harley Quinn underwater!#Harley Quinn #joker
00:49
Harley Quinn with the Joker
Рет қаралды 39 МЛН
Content Modeling [ how to structure your data in Strapi ]
33:03
Using Strapi v4 with Docker
6:45
Strapi
Рет қаралды 22 М.
Strapi.js Crash Course | Headless CMS
25:06
Traversy Media
Рет қаралды 364 М.
Building data relations in Strapi
8:37
Strapi
Рет қаралды 31 М.
Strapi: Free Open Source Headless CMS
14:01
Elestio
Рет қаралды 11 М.
Building Custom APIs With Strapi
53:35
DigitalOcean
Рет қаралды 52 М.
Updating Your Own User Info in Strapi
9:10
Strapi
Рет қаралды 6 М.
Components and Dynamic Zones 🚀 Strapi Course #2
23:12
NL Tech
Рет қаралды 4,5 М.