fix(api): fix api endpoint logic #2

This commit is contained in:
shafin-r
2025-08-16 17:05:40 +06:00
parent 713696760e
commit ad46bf954e
5 changed files with 40 additions and 41 deletions

View File

@ -1,4 +1,6 @@
export const API_URL = "https://examjam-api.pptx704.com";
import { LoginForm, RegisterForm } from "@/types/auth";
export const API_URL = "https://examjam-backend.omukk.dev";
// Cookie utility function
const setCookie = (name: string, value: string | null, days: number = 7) => {
@ -15,12 +17,6 @@ const setCookie = (name: string, value: string | null, days: number = 7) => {
}
};
interface AuthForm {
email: string;
password: string;
[key: string]: any; // for flexibility
}
type SetTokenFn = (token: string) => void;
// Optional: Create a custom error type to carry extra data
@ -29,7 +25,7 @@ interface APIError extends Error {
}
export const login = async (
form: AuthForm,
form: LoginForm,
setToken: SetTokenFn
): Promise<void> => {
const response = await fetch(`${API_URL}/auth/login`, {
@ -51,7 +47,7 @@ export const login = async (
};
export const register = async (
form: AuthForm,
form: RegisterForm,
setToken: SetTokenFn
): Promise<void> => {
const response = await fetch(`${API_URL}/auth/register`, {