Keep in mind, that first part of the handler is the Filename. You mentioned that you created a Users.js file with controller suggestedusers, but from routes you are accessing the userpermissions.js file, so it doesn’t contain your custom controller suggestedusers.
Look at the screenshot bellow:
To achieve your needs:
- Create the controller file
/extensions/users-permissions/controllers/custom.js
:
module.exports = {
suggestedUsers: async (ctx, next) => {
console.log('/suggested-users accessed.');
await next();
}
};
- Create the route file
extensions/users-permissions/config/routes.json
:
{
"routes": [
{
"method": "GET",
"path": "/suggested-users",
"handler": "custom.suggestedUsers",
"config": {
"policies": []
}
}
]
}
- Make the route public or accessible only for authenticated.
- Profit: