getGroup
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 6s

This commit is contained in:
Kanjana 2025-04-22 15:12:24 +07:00
parent 94c7de89eb
commit 8b26f91dba

View file

@ -347,7 +347,7 @@ export async function removeUserRoles(userId: string, roles: { id: string; name:
}
export async function getGroup() {
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups`, {
const res = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups?q`, {
headers: {
authorization: `Bearer ${await getToken()}`,
"content-type": `application/json`,
@ -356,20 +356,10 @@ export async function getGroup() {
});
const dataMainGroup = await res.json();
const fetchSubGroups = async (group: any) => {
const resSub = await fetch(`${KC_URL}/admin/realms/${KC_REALM}/groups/${group.id}/children`, {
headers: {
authorization: `Bearer ${await getToken()}`,
"content-type": `application/json`,
},
method: "GET",
});
const dataSubGroup = await resSub.json();
let fullSubGroup = await Promise.all(
dataSubGroup.map(async (subGroupsData: any) => {
if (subGroupsData.subGroupCount > 0) {
group.subGroups.map(async (subGroupsData: any) => {
if (group.subGroupCount > 0) {
return await fetchSubGroups(subGroupsData);
} else {
return {