From e1b0bef261eb1e11634011fc990cfa92adf88c18 Mon Sep 17 00:00:00 2001 From: Mac mini <> Date: Tue, 31 Mar 2026 17:55:00 +0700 Subject: [PATCH] update axios --- src/service/auth.ts | 47 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 34 deletions(-) diff --git a/src/service/auth.ts b/src/service/auth.ts index 8eaeb8e..4c6aeb0 100644 --- a/src/service/auth.ts +++ b/src/service/auth.ts @@ -1,53 +1,32 @@ -import axiosInstance from "@/config/axiosInstance"; -import { API } from "../../api"; 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 response = await fetch(API.Auth.CREATEOTP, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ email, token_type }), + const response = await api.post(API.Auth.CREATEOTP, { + email, + token_type }); - return response.json(); + return response.data; }; export const apiVerifyOTP = async (email: string, token: string) => { const body = { email, token, token_type: 2 }; - const response = await fetch(API.Auth.VERIFYOTP, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(body), - }); - return response.json(); + const response = await api.post(API.Auth.VERIFYOTP, body); + return response.data; }; export const apiSignUp = async (payload: any) => { - const response = await fetch(API.Auth.SIGNUP, { - method: "POST", - headers: { "Content-Type": "application/json" }, - body: JSON.stringify(payload), - }); - return response.json(); + const response = await api.post(API.Auth.SIGNUP, payload); + return response.data; }; export const apiSignIn = async (payload: any) => { - const response = await fetch(API.Auth.SIGNIN, { - method: "POST", - headers: { "Content-Type": "application/json" }, - credentials: "include", - body: JSON.stringify(payload), - }); - return response.json(); + const response = await api.post(API.Auth.SIGNIN, payload); + return response.data; }; export const apiGetCurrentUser = async () => { const response = await api.get(API.User.CURRENT); return response?.data; -}; - -export interface ApiResponse { - status: boolean - data: T - message?: string -} \ No newline at end of file +}; \ No newline at end of file