paging getList

This commit is contained in:
Bright 2024-05-30 15:24:38 +07:00
parent aef313bac7
commit 7fdd950c85
2 changed files with 6 additions and 5 deletions

View file

@ -123,9 +123,10 @@ export async function getUser(userId: string) {
*
* @returns user list if success, false otherwise.
*/
export async function getUserList(search = "") {
export async function getUserList(first = "", max = "", search = "") {
const res = await fetch(
`${KC_URL}/admin/realms/${KC_REALM}/users`.concat(!!search ? `?search=${search}` : ""),
// `${KC_URL}/admin/realms/${KC_REALM}/users`.concat(!!search ? `?search=${search}` : ""),
`${KC_URL}/admin/realms/${KC_REALM}/users?first=${first || "0"}&max=${max || "-1"}${search ? `&search=${search}` : ""}`,
{
// prettier-ignore
headers: {
@ -140,7 +141,7 @@ export async function getUserList(search = "") {
return Boolean(console.error("Keycloak Error Response: ", await res.json()));
}
return ((await res.json()) as any[]).map((v: Record<string, string>) => ({
return ((await res.json()) as any[]).slice(0, 5000).map((v: Record<string, string>) => ({
id: v.id,
username: v.username,
firstName: v.firstName,