From 972ea43dfca1443a4a36503e7e819dd524694980 Mon Sep 17 00:00:00 2001 From: Fredrik Strand Oseberg Date: Fri, 11 Feb 2022 12:13:03 +0100 Subject: [PATCH] fix: do not use formatApiPath on paths from API (#702) * fix: do not use formatApiPath on paths from API * fix: remove createRequest --- .../api/actions/useAuthApi/useAuthApi.tsx | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx b/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx index 9e5e2bb907..555b6ddc42 100644 --- a/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx +++ b/frontend/src/hooks/api/actions/useAuthApi/useAuthApi.tsx @@ -1,3 +1,4 @@ +import { headers } from '../../../../utils/api-utils'; import useAPI from '../useApi/useApi'; type PasswordLogin = ( @@ -16,24 +17,36 @@ interface IUseAuthApiOutput { } export const useAuthApi = (): IUseAuthApiOutput => { - const { makeRequest, createRequest, errors, loading } = useAPI({ + const { makeRequest, errors, loading } = useAPI({ propagateErrors: true, }); const passwordAuth = (path: string, username: string, password: string) => { - const req = createRequest(ensureRelativePath(path), { - method: 'POST', - body: JSON.stringify({ username, password }), - }); + const req = { + caller: () => { + return fetch(path, { + headers, + method: 'POST', + body: JSON.stringify({ username, password }), + }); + }, + id: 'passwordAuth', + }; return makeRequest(req.caller, req.id); }; const emailAuth = (path: string, email: string) => { - const req = createRequest(ensureRelativePath(path), { - method: 'POST', - body: JSON.stringify({ email }), - }); + const req = { + caller: () => { + return fetch(path, { + headers, + method: 'POST', + body: JSON.stringify({ email }), + }); + }, + id: 'emailAuth', + }; return makeRequest(req.caller, req.id); };