fix:local api

This commit is contained in:
Anang Yusman 2026-01-20 20:43:12 +08:00
parent f516565446
commit a5360837c7
1 changed files with 18 additions and 10 deletions

View File

@ -1,16 +1,13 @@
/**
* Service untuk memanggil API lokal (localhost:8800)
* Menggunakan endpoint dari .env
*
*
* Contoh penggunaan:
* - Set NEXT_PUBLIC_API_BASE_URL=http://localhost:8800 di file .env.local
* - Atau gunakan NEXT_PUBLIC_LOCAL_API_URL jika ingin endpoint terpisah
*/
import {
httpGet,
httpPost,
} from "./http-config/http-base-services";
import { httpGet, httpPost } from "./http-config/http-base-services";
import {
httpGetInterceptor,
@ -26,7 +23,11 @@ export async function getDataFromLocal(endpoint: string, headers?: any) {
return await httpGet(endpoint, headers);
}
export async function postDataToLocal(endpoint: string, data: any, headers?: any) {
export async function postDataToLocal(
endpoint: string,
data: any,
headers?: any,
) {
return await httpPost(endpoint, data, headers);
}
@ -34,14 +35,22 @@ export async function postDataToLocal(endpoint: string, data: any, headers?: any
// Menggunakan axios-interceptor-instance.ts dengan Bearer token
export async function getDataWithAuth(endpoint: string, headers?: any) {
return await httpGetInterceptor(endpoint, headers);
return await httpGet(endpoint, headers);
}
export async function postDataWithAuth(endpoint: string, data: any, headers?: any) {
export async function postDataWithAuth(
endpoint: string,
data: any,
headers?: any,
) {
return await httpPostInterceptor(endpoint, data, headers);
}
export async function updateDataWithAuth(endpoint: string, data: any, headers?: any) {
export async function updateDataWithAuth(
endpoint: string,
data: any,
headers?: any,
) {
return await httpPutInterceptor(endpoint, data, headers);
}
@ -71,4 +80,3 @@ export async function updateUser(id: string | number, data: any) {
export async function deleteUser(id: string | number) {
return await httpDeleteInterceptor(`/users/${id}`);
}