mirror of
https://github.com/Unleash/unleash.git
synced 2025-08-04 13:48:56 +02:00
fix: do not use formatApiPath on paths from API (#702)
* fix: do not use formatApiPath on paths from API * fix: remove createRequest
This commit is contained in:
parent
4a013c125f
commit
972ea43dfc
@ -1,3 +1,4 @@
|
|||||||
|
import { headers } from '../../../../utils/api-utils';
|
||||||
import useAPI from '../useApi/useApi';
|
import useAPI from '../useApi/useApi';
|
||||||
|
|
||||||
type PasswordLogin = (
|
type PasswordLogin = (
|
||||||
@ -16,24 +17,36 @@ interface IUseAuthApiOutput {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const useAuthApi = (): IUseAuthApiOutput => {
|
export const useAuthApi = (): IUseAuthApiOutput => {
|
||||||
const { makeRequest, createRequest, errors, loading } = useAPI({
|
const { makeRequest, errors, loading } = useAPI({
|
||||||
propagateErrors: true,
|
propagateErrors: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const passwordAuth = (path: string, username: string, password: string) => {
|
const passwordAuth = (path: string, username: string, password: string) => {
|
||||||
const req = createRequest(ensureRelativePath(path), {
|
const req = {
|
||||||
method: 'POST',
|
caller: () => {
|
||||||
body: JSON.stringify({ username, password }),
|
return fetch(path, {
|
||||||
});
|
headers,
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ username, password }),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
id: 'passwordAuth',
|
||||||
|
};
|
||||||
|
|
||||||
return makeRequest(req.caller, req.id);
|
return makeRequest(req.caller, req.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
const emailAuth = (path: string, email: string) => {
|
const emailAuth = (path: string, email: string) => {
|
||||||
const req = createRequest(ensureRelativePath(path), {
|
const req = {
|
||||||
method: 'POST',
|
caller: () => {
|
||||||
body: JSON.stringify({ email }),
|
return fetch(path, {
|
||||||
});
|
headers,
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({ email }),
|
||||||
|
});
|
||||||
|
},
|
||||||
|
id: 'emailAuth',
|
||||||
|
};
|
||||||
|
|
||||||
return makeRequest(req.caller, req.id);
|
return makeRequest(req.caller, req.id);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user