From b879392d370d5d8e65a1214c322b1000ef0ad7da Mon Sep 17 00:00:00 2001 From: Alberto Defendi <1369-ahl-berto@users.noreply.gitlab.inf.unibz.it> Date: Sun, 16 May 2021 18:05:04 +0200 Subject: [PATCH] Start rewriting of login request in separate file using async/await. --- .../AuthUser/SignInForm/postCredentials.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/components/AuthUser/SignInForm/postCredentials.ts diff --git a/src/components/AuthUser/SignInForm/postCredentials.ts b/src/components/AuthUser/SignInForm/postCredentials.ts new file mode 100644 index 0000000..b55f4bc --- /dev/null +++ b/src/components/AuthUser/SignInForm/postCredentials.ts @@ -0,0 +1,23 @@ +import axios from 'axios'; +import { CredentialsType } from './CredentialsType'; + +export const fetchCookie = async ( + values: CredentialsType, + cookie: React.Dispatch<React.SetStateAction<string>>, +): Promise<unknown> => { + const response = await axios.post( + '/api/web/login', + { + username: values.username, + password: values.password, + csrfmiddlewaretoken: cookie, + }, + { + headers: { + 'Content-Type': 'application/json', + }, + }, + ); + + return null; +}; -- GitLab