Files
hipmi/src/app_modules/auth/_lib/api_fetch_auth.ts
Bagasbanuna02 61f8e03c73 fix registrasi
deskripsi:
- fix registrasi dan middleware
2025-02-05 17:48:45 +08:00

74 lines
1.6 KiB
TypeScript

export {
apiFetchLogin,
apiGetCheckCodeOtp,
apiPostVerifikasiCodeOtp,
apiDeleteAktivasiKodeOtpByNomor,
apiFetchRegister,
};
const apiFetchLogin = async ({ nomor }: { nomor: string }) => {
const respone = await fetch("/api/auth/login", {
method: "POST",
body: JSON.stringify({ nomor: nomor }),
headers: {
"Content-Type": "application/json",
},
});
return await respone.json().catch(() => null);
};
const apiGetCheckCodeOtp = async ({ id }: { id: string }) => {
const respone = await fetch(`/api/auth/check/${id}`);
return await respone.json().catch(() => null);
};
const apiPostVerifikasiCodeOtp = async ({ nomor }: { nomor: string }) => {
const respone = await fetch("/api/auth/validasi", {
method: "POST",
body: JSON.stringify({ nomor: nomor }),
headers: {
"Content-Type": "application/json",
},
});
return await respone.json().catch(() => null);
};
const apiDeleteAktivasiKodeOtpByNomor = async ({ id }: { id: string }) => {
const respone = await fetch(`/api/auth/code/${id}`, {
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
});
return await respone.json().catch(() => null);
};
const apiFetchRegister = async ({
nomor,
username,
}: {
nomor: string;
username: string;
}) => {
const data = {
username: username,
nomor: nomor,
};
const respone = await fetch("/api/auth/register", {
method: "POST",
body: JSON.stringify({ data }),
headers: {
"Content-Type": "application/json",
},
});
const result = await respone.json();
return result;
// return await respone.json().catch(() => null);
};