update axios

This commit is contained in:
Mac mini
2026-03-31 17:55:00 +07:00
parent 1674632b0f
commit e1b0bef261

View File

@@ -1,53 +1,32 @@
import axiosInstance from "@/config/axiosInstance";
import { API } from "../../api";
import api from "@/config/config"; import api from "@/config/config";
import { API } from "../../api";
export const apiCreateOTP = async (email : string) => { export const apiCreateOTP = async (email: string) => {
const token_type = 2; const token_type = 2;
const response = await fetch(API.Auth.CREATEOTP, { const response = await api.post(API.Auth.CREATEOTP, {
method: "POST", email,
headers: { "Content-Type": "application/json" }, token_type
body: JSON.stringify({ email, token_type }),
}); });
return response.json(); return response.data;
}; };
export const apiVerifyOTP = async (email: string, token: string) => { export const apiVerifyOTP = async (email: string, token: string) => {
const body = { email, token, token_type: 2 }; const body = { email, token, token_type: 2 };
const response = await fetch(API.Auth.VERIFYOTP, { const response = await api.post(API.Auth.VERIFYOTP, body);
method: "POST", return response.data;
headers: { "Content-Type": "application/json" },
body: JSON.stringify(body),
});
return response.json();
}; };
export const apiSignUp = async (payload: any) => { export const apiSignUp = async (payload: any) => {
const response = await fetch(API.Auth.SIGNUP, { const response = await api.post(API.Auth.SIGNUP, payload);
method: "POST", return response.data;
headers: { "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
return response.json();
}; };
export const apiSignIn = async (payload: any) => { export const apiSignIn = async (payload: any) => {
const response = await fetch(API.Auth.SIGNIN, { const response = await api.post(API.Auth.SIGNIN, payload);
method: "POST", return response.data;
headers: { "Content-Type": "application/json" },
credentials: "include",
body: JSON.stringify(payload),
});
return response.json();
}; };
export const apiGetCurrentUser = async () => { export const apiGetCurrentUser = async () => {
const response = await api.get(API.User.CURRENT); const response = await api.get(API.User.CURRENT);
return response?.data; return response?.data;
}; };
export interface ApiResponse<T> {
status: boolean
data: T
message?: string
}