added POST-endpoint for userform

Co-authored-by: haraldnilsen <harald_998@hotmail.com>
Signed-off-by: Sindre Kjelsrud <kjelsrudsindre@gmail.com>
This commit is contained in:
Sindre Kjelsrud 2023-12-21 19:31:14 +01:00
parent b78003b4fc
commit dd8f22b043
Signed by untrusted user who does not match committer: sidski
GPG key ID: D2BBDF3EDE6BA9A6
7 changed files with 74 additions and 18 deletions

View file

@ -0,0 +1,22 @@
export const postFormData = (
age: string,
education: string,
healthcare_personnel: string,
gender: string
) => {
let url = "http://localhost:8080/submitform";
let personnel = healthcare_personnel == "Ja" ? true : false;
const response = fetch(url, {
method: "POST",
body: JSON.stringify({
age: age,
education: education,
healthcare_personnel: personnel,
gender: gender,
}),
}).catch((error) => {
console.log(error);
});
return response;
};