diff --git a/src/app/personside/infotabs/saksoversikt/dokumentvisning/SaksDokumentVisning.tsx b/src/app/personside/infotabs/saksoversikt/dokumentvisning/SaksDokumentVisning.tsx index dfbdb7975..136c1f7f7 100644 --- a/src/app/personside/infotabs/saksoversikt/dokumentvisning/SaksDokumentVisning.tsx +++ b/src/app/personside/infotabs/saksoversikt/dokumentvisning/SaksDokumentVisning.tsx @@ -44,7 +44,7 @@ function DokumentVisning(props: Props) { const url = getMockableUrl(byggDokumentVisningUrl(props.url, props.fnr)); return ( - + {errMsg} diff --git a/src/components/ObjectHttpFeilHandtering.tsx b/src/components/ObjectHttpFeilHandtering.tsx index bebd1822f..aedf47cbf 100644 --- a/src/components/ObjectHttpFeilHandtering.tsx +++ b/src/components/ObjectHttpFeilHandtering.tsx @@ -12,22 +12,25 @@ interface Props export function ObjectHttpFeilHandtering({ url, onError, children, ...rest }: Props) { const [blobUrl, setBlobUrl] = useState(''); + const [contentType, setContentType] = useState(''); const [isError, setError] = useState(false); useEffect(() => { let objectUrl = ''; fetch(url) - .then(res => { + .then((res) => { if (!res.ok) { setError(true); onError(res.status); } else { + setContentType(res.headers.get('Content-Type') ?? 'application/pdf'); setError(false); } return res.blob(); }) - .then(blob => { + .then((blob) => { objectUrl = URL.createObjectURL(blob); + setBlobUrl(objectUrl); }); @@ -42,5 +45,5 @@ export function ObjectHttpFeilHandtering({ url, onError, children, ...rest }: Pr return <>{children}; } - return ; + return ; }