diff --git a/src/utils/auth/login.js b/src/utils/auth/login.js deleted file mode 100644 index 1d99d02..0000000 --- a/src/utils/auth/login.js +++ /dev/null @@ -1,13 +0,0 @@ -import fetchWrapper from "../fetchWrapper.js"; -import getXSRFToken from "../getXSRF.js"; - -export default async function login(email, password) { - const csrfToken = await getXSRFToken(); - - return fetchWrapper( - "/api/users/login", - { email, password }, - "POST", - { "X-XSRF-TOKEN": csrfToken } - ); -} diff --git a/src/utils/auth/login.ts b/src/utils/auth/login.ts new file mode 100644 index 0000000..3c7c6e2 --- /dev/null +++ b/src/utils/auth/login.ts @@ -0,0 +1,14 @@ +import fetchWrapper from "../fetchWrapper"; +import getXSRFToken from "../getXSRF"; + + + +export default async function login(email: string, password: string) { + const csrfToken: string = await getXSRFToken(); + return fetchWrapper( + "/api/users/login", + { email, password }, + "POST", + { "X-XSRF-TOKEN": csrfToken } + ); +} \ No newline at end of file diff --git a/src/utils/fetchWrapper.ts b/src/utils/fetchWrapper.ts index a130373..287e683 100644 --- a/src/utils/fetchWrapper.ts +++ b/src/utils/fetchWrapper.ts @@ -1,43 +1,3 @@ -/*export default async function fetchWrapper(path,data = null,method = "GET",headers = {}) { - try { - const res = await fetch( - `${import.meta.env.VITE_API_URL}${path}`, - { - method, - credentials: "include", - headers: { - "Accept": "application/json", - "Content-Type": "application/json", - ...headers, - }, - body: data ? JSON.stringify(data) : null, - } - ); - - let responseData = null; - - try { - responseData = await res.json(); - } catch (_) { - responseData = null; - } - - return { - status: res.status, - data: responseData, - }; - - } catch (err) { - console.error("❌ Erreur réseau :", err); - - return { - status: 0, - data: { - message: "Network error", - }, - }; - } -}*/ interface FetchResponse { status: number;