From 70d813758d3246e1770eee630bc5a21407a5bcbb Mon Sep 17 00:00:00 2001 From: Markus Johansen Date: Tue, 4 Jul 2023 12:05:38 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=97=EF=B8=8F=20Satt=20opp=20axios=20ti?= =?UTF-8?q?l=20gj=C3=B8re=20kall=20mot=20ktor=20applikasjon?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sindre Kjelsrud Co-authored-by: Amalie Mansåker --- frontend/pages/index.tsx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/frontend/pages/index.tsx b/frontend/pages/index.tsx index 57f992e..50a742e 100644 --- a/frontend/pages/index.tsx +++ b/frontend/pages/index.tsx @@ -1,21 +1,18 @@ import "@navikt/ds-css"; - import { Button, Heading } from "@navikt/ds-react"; - -const axios=require('axios').default - - - +import axios , { AxiosError } from "axios"; +import { log } from "console"; +import { useState } from "react"; //useSWR hilsen Emil ;D async function getWorld() { - axios.get("/") - .then((response : any) => { - console.log(response); - }).catch((error : any) => { + try { + const {data} : {data: any} = await axios.get("http://0.0.0.0:8080/"); + console.log(data); + return data + } catch (error) { console.log(error); - }) + } } - export default function Home() { getWorld(); @@ -25,6 +22,7 @@ export default function Home() { Sprik + {/*

{getWorld()}

*/} )