🍻 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>
This commit is contained in:
Sindre Kjelsrud 2023-07-04 15:56:01 +02:00
parent a8446b6b73
commit fdf54063c2
4 changed files with 54 additions and 0 deletions

View file

@ -1,6 +1,7 @@
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)
@ -10,6 +11,23 @@ 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">