diff --git a/apps/dolly-frontend/src/main/js/src/service/services/pdl/PdlForvalterService.tsx b/apps/dolly-frontend/src/main/js/src/service/services/pdl/PdlForvalterService.tsx index ee25d3016f2..e5547009be2 100644 --- a/apps/dolly-frontend/src/main/js/src/service/services/pdl/PdlForvalterService.tsx +++ b/apps/dolly-frontend/src/main/js/src/service/services/pdl/PdlForvalterService.tsx @@ -2,13 +2,30 @@ import Request from '@/service/services/Request' const getPdlUrl = () => '/testnav-pdl-forvalter/api/v1' +const sliceIdentListe = (identListe: string[]) => { + const maxAntall = 150 + if (identListe.length <= maxAntall) return [identListe] + const identer = [] + for (let i = 0; i < identListe.length; i += maxAntall) { + identer.push(identListe.slice(i, i + maxAntall)) + } + return identer +} + export default { getPersoner(identListe: string[]) { if (!identListe) { return } - const endpoint = `${getPdlUrl()}/personer?identer=${identListe}` - return Request.get(endpoint) + const identerDelt = sliceIdentListe(identListe) + const promises = identerDelt.map((identer) => { + const endpoint = `${getPdlUrl()}/personer?identer=${identer}` + return Request.get(endpoint) + }) + return Promise.all(promises).then((responses) => { + const data = responses.map((response: any) => response?.data).flat() + return { data } + }) }, soekPersoner(fragment: string) { if (!fragment || fragment.length > 11) {