Skip to content

Commit

Permalink
useEffect med fetch #deploy-frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrea-Devold-Fjeld committed Jul 22, 2024
1 parent 0023045 commit 54c7f52
Showing 1 changed file with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,34 @@ import { Alert } from '@navikt/ds-react'
import { AppstyringTable } from '@/pages/adminPages/Appstyring/AppstyringTable'
import { erDollyAdmin } from '@/utils/DollyAdmin'
import data from "@navikt/ds-icons/src/Data";
import React, { useState, useEffect } from "react";

export default () => {
if (!erDollyAdmin()) {
return <AdminAccessDenied />
}

let data: {parameter: string, verdi: string, verdier: {verdi: string, navn: string}[] }[] = [];
useEffect(() => {
fetch("/testnav-levende-arbeidsforhold-ansettelse/api", {
method: "GET"})
.then((response) => response.json())
.then(data => {
for (const parameter of data) {
let verdier: {verdi: string, navn: string}[] = [];
for (const verdi of data.verdier) {
verdier.push({verdi: verdi.verdi, navn: verdi.navn });
}
data.push({parameter: parameter.navn, verdi: parameter.verdi, verdier: verdier});
}
})
.then(json=>console.log(json));
});

//const headers = { 'Authorization': 'Bearer ' };
/*
fetch('/testnav-levende-arbeidsforhold-ansettelse/api')
.then(res=>res.json())
.then((data) => {
for (const parameter of data) {
Expand All @@ -24,6 +43,8 @@ export default () => {
})
.then(json=>console.log(json));
*/

//TODO: Implementer henting av data fra backend
const dataMock = [
{ parameter: 'Parameter 1', verdi: 'verdi1' },
Expand Down

0 comments on commit 54c7f52

Please sign in to comment.