From 38239a378b36ff0cf16880f5b55afb2fc0256fe0 Mon Sep 17 00:00:00 2001 From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it> Date: Sat, 20 Mar 2021 17:45:43 +0100 Subject: [PATCH] Preconfigured login url --- src/components/LoginForm/index.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/LoginForm/index.tsx b/src/components/LoginForm/index.tsx index fea60f6..310bf4b 100644 --- a/src/components/LoginForm/index.tsx +++ b/src/components/LoginForm/index.tsx @@ -35,6 +35,15 @@ export const Form: React.FC = () => { }; const [formValues, setFormValues] = useState<formData>(defaultValues); + const requestOptions = { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + email: formValues.email, + password: formValues.password, + }), + }; + const handleSubmit = (event: React.FormEvent): void => { event.preventDefault(); const errors: Array<string> = []; @@ -43,6 +52,10 @@ export const Form: React.FC = () => { console.log('Email address not valid'); } else { console.log(formValues); + fetch( + 'https://jsonplaceholder.typicode.com/posts', + requestOptions, + ).then((response) => response.json()); } }; -- GitLab