Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
422 views
in Technique[技术] by (71.8m points)

customization - Custom handler in Strapi

I'm trying to create a custom route and handler for user-permissions but it's not working. Not sure though if my method is wrong or cannot be done. By the way here is my code.

/config/routes.json

{
  "routes": [
    {
      "method": "PUT",
      "path": "/users/:id/approve",
      "handler": "users.approve",
      "config": {
        "policies": []
      }
    }
  ]
}

/controllers/Users.js

module.exports = {
    approve: async ctx => {
        const { id } = ctx.params;
        console.log('approve user')
    }
};

From routes, the handler should read the approve in controller but the strapi threw error TypeError: Cannot read property 'approve' of undefined

question from:https://stackoverflow.com/questions/66061988/custom-handler-in-strapi

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...