How to check if username is already taken every change on textfield?

Hello, I would like to know how to check if an username is already taken everytime the user write on textefield like this picture,

The attribute “username” is already unique, but I have to submit the form to know if its already taken or not.

The best solution I could find yet, is to get all the username, store it in Array, and compare everytime there is a change on textfield where the user have to enter an “username”

anyone please

You can make a custom endpoint that checks if the username is taken or not.

Something like…

  async isUsernameAvailable(ctx) {
    let users = await strapi.entityService.findMany(
      "plugin::users-permissions.user", { filters: { username: ctx.params.username }}
    );

    return users.length === 0;
  }
1 Like

thank you dear !