This repository has been archived on 2024-12-07. You can view files and clone it, but cannot push or open issues or pull requests.
helse-sprik/frontend/pages/index.tsx
Sindre Kjelsrud fdf54063c2 🍻 POST-request m/ payload mot backend lagt til + jackson (heehee)
Co-authored-by: Amalie Erdal Mansåker <amalie.erdal.mansaker@nav.no>
Co-authored-by: Markus A. R. Johansen <markus.aleksander.rakil.johansen@nav.no>
2023-07-04 15:56:01 +02:00

42 lines
1.1 KiB
TypeScript

import "@navikt/ds-css";
import { Button, Heading } from "@navikt/ds-react";
import axios , { Axios, AxiosError } from "axios";
import { log } from "console";
import useSWR from "swr";
const fetcher = (url: any) => axios.get(url).then(res => res.data)
export default function Home() {
const {data, error, isLoading} = useSWR('http://0.0.0.0:8080/', fetcher);
console.log(data);
function post() {
axios.post("http://0.0.0.0:8080/test", {
ord: "heisann hoppsann",
tall: 7
}, {
headers: {
'Content-Type': 'application/json'
}
}).then( (response) => {
console.log(response)
}).catch( (error) => {
console.log(error);
})
}
post()
return (
<main className="flex justify-center">
<div className="w-1/2 flex flex-col gap-4 justify-center text-center">
<Heading level="1" size="xlarge">Sprik</Heading>
<Button variant="primary">Meld inn feil</Button>
<Button variant="secondary">Meld inn funksjonalitetsønsker</Button>
{data ? <div>{data}</div> : <div>Laster</div>}
</div>
</main>
)
}