From 6af3757892ff1cc3e1703e7e9eb5df43c39edb23 Mon Sep 17 00:00:00 2001 From: AaronNazareth <4nm20cs005@nmamit.in> Date: Tue, 26 Sep 2023 19:28:39 +0530 Subject: [PATCH] fix: request body error --- src/Components/Auth/Login.tsx | 8 ++++---- src/Components/Auth/ResetPassword.tsx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Components/Auth/Login.tsx b/src/Components/Auth/Login.tsx index 01596b85d09..1f19550b50d 100644 --- a/src/Components/Auth/Login.tsx +++ b/src/Components/Auth/Login.tsx @@ -95,9 +95,10 @@ export const Login = (props: { forgot?: boolean }) => { // replaces button with spinner setLoading(true); - const { res, data } = await request(routes.login, { - pathParams: { ...valid }, + const { res, data, error } = await request(routes.login, { + body: { ...valid }, }); + console.log(res, data, error); if (res && res.status === 429) { setCaptcha(true); // captcha displayed set back to login button @@ -105,7 +106,6 @@ export const Login = (props: { forgot?: boolean }) => { } else if (res && res.status === 200 && data) { localStorage.setItem(LocalStorageKeys.accessToken, data.access); localStorage.setItem(LocalStorageKeys.refreshToken, data.refresh); - if ( window.location.pathname === "/" || window.location.pathname === "/login" @@ -149,7 +149,7 @@ export const Login = (props: { forgot?: boolean }) => { if (valid) { setLoading(true); const { res, error } = await request(routes.forgotPassword, { - pathParams: { ...valid }, + body: { ...valid }, }); setLoading(false); if (res && res.statusText === "OK") { diff --git a/src/Components/Auth/ResetPassword.tsx b/src/Components/Auth/ResetPassword.tsx index 8a29decd4f1..2f02737f6de 100644 --- a/src/Components/Auth/ResetPassword.tsx +++ b/src/Components/Auth/ResetPassword.tsx @@ -70,7 +70,7 @@ export const ResetPassword = (props: any) => { if (valid) { valid.token = props.token; const { res, error } = await request(routes.resetPassword, { - pathParams: { ...valid }, + body: { ...valid }, }); if (res && res.statusText === "OK") { localStorage.removeItem(LocalStorageKeys.accessToken); @@ -87,7 +87,7 @@ export const ResetPassword = (props: any) => { useEffect(() => { const checkResetToken = async () => { const { res } = await request(routes.checkResetToken, { - pathParams: { token: props.token }, + body: { token: props.token }, }); if (!res || res.statusText !== "OK") { navigate("/invalid-reset");