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() { 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: { headers: {
authorization: `Bearer ${await getToken()}`, authorization: `Bearer ${await getToken()}`,
"content-type": `application/json`, "content-type": `application/json`,
@ -356,20 +356,10 @@ export async function getGroup() {
}); });
const dataMainGroup = await res.json(); const dataMainGroup = await res.json();
const fetchSubGroups = async (group: any) => { 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( let fullSubGroup = await Promise.all(
dataSubGroup.map(async (subGroupsData: any) => { group.subGroups.map(async (subGroupsData: any) => {
if (subGroupsData.subGroupCount > 0) { if (group.subGroupCount > 0) {
return await fetchSubGroups(subGroupsData); return await fetchSubGroups(subGroupsData);
} else { } else {
return { return {