convert login.js to TS

This commit is contained in:
p2405951
2026-03-13 15:16:50 +01:00
parent 0f11ec641a
commit 8d21eb7a77
3 changed files with 14 additions and 53 deletions
-13
View File
@@ -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 }
);
}
+14
View File
@@ -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 }
);
}
-40
View File
@@ -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<T = any> {
status: number;