fix bug getListUser

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-05-31 13:53:08 +07:00
parent c30f4eb572
commit 43a1dfe8d2
2 changed files with 10 additions and 7 deletions

View file

@ -209,7 +209,7 @@ export class KeycloakController extends Controller {
@Get("user")
async getUserList(@Query() first = "", @Query() max = "", @Query() search = "") {
const total = await getUserCount();
const total = await getUserCount(first, max, search);
const result = await getUserList(first, max, search);
if (Array.isArray(result)) {

View file

@ -150,13 +150,16 @@ export async function getUserList(first = "", max = "", search = "") {
}));
}
export async function getUserCount() {
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/users/count`, {
headers: {
authorization: `Bearer ${await getToken()}`,
"content-type": `application/json`,
export async function getUserCount(first = "", max = "", search = "") {
const res = await fetch(
`${KC_URL}/admin/realms/${KC_REALM}/users/count?first=${first || "0"}&max=${max || "-1"}${search ? `&search=${search}` : ""}`,
{
headers: {
authorization: `Bearer ${await getToken()}`,
"content-type": `application/json`,
},
},
}).catch((e) => console.log("Keycloak Error: ", e));
).catch((e) => console.log("Keycloak Error: ", e));
if (!res) return false;
if (!res.ok) {