Custom users permissons api

System Information
  • Strapi Version: 4.1.3
  • Operating System: linux
  • Database: mysql
  • Node Version: 14.19.1
  • NPM Version: 6.14.16
  • Yarn Version: 1.22.17

I’m trying to custom response of users-permissions plugin. When i’m trying to request api from postman, i got this response:
Here’s my code:

plugin.controllers.user.find = async (ctx) => {
        const response = await strapi.plugins['users-permissions'].services.user.fetchAll(ctx.query, '*');
        return transformResponse(response);

And i got this response:

[2022-03-23 12:26:38.268] error: Where must be an object
Error: Where must be an object

Someone can explain what’s wrong with my code.

@Lam_Le_Vu Though js can not find the type, but you can use toString() print the function you apply. in you code’s async function, you can do console print:


then you will find the fetchAll function’s args should be like {where: params, populate}:

fetchAll(params, populate) {
    return strapi.query('plugin::users-permissions.user').findMany({ where: params, populate });

then you console log findMany

findMany(params) {
      return db.entityManager.findMany(uid, params);

then you will find it maybe use db queryEngine, then find in strapi docs of db query engine, findMany here : Single Operations for Query Engine API - Strapi Developer Docs

found that where should be an object, I think the error caused here. I hope it can help.

then find where details Filtering Operations for Query Engine API - Strapi Developer Docs

thanks, i will try to do this :grinning: