feat: fixing http service & config

This commit is contained in:
hanif salafi 2025-07-08 11:41:50 +07:00
parent 47402ea655
commit bee5dcadb6
5 changed files with 8 additions and 17 deletions

View File

@ -230,8 +230,5 @@ export async function deleteSPIT(id: any) {
export async function postActivityLog(data: any) {
const url = `activity`;
const headers = {
"content-type": "application/json",
};
return httpPost(url, headers, data);
return httpPost(url, data);
}

View File

@ -4,7 +4,7 @@ import Cookies from "js-cookie";
import qs from "qs";
import { getCsrfToken } from "../auth";
export async function httpPost(pathUrl: any, headers: any, data?: any) {
export async function httpPost(pathUrl: any, data?: any, headers?: any,) {
const resCsrf = await getCsrfToken();
const csrfToken = resCsrf?.data?.token;
const authToken = Cookies.get("access_token");
@ -15,9 +15,9 @@ export async function httpPost(pathUrl: any, headers: any, data?: any) {
const mergedHeaders = {
...defaultHeaders,
...headers,
...(csrfToken ? { "X-XSRF-TOKEN": csrfToken } : {}),
...(authToken ? { "Authorization" : `Bearer ${authToken}`} : {}),
...headers,
};
const response = await axiosBaseInstance

View File

@ -74,8 +74,8 @@ export async function httpPostInterceptor(
};
const mergedHeaders = {
...defaultHeaders,
...headers,
...(csrfToken ? { "X-XSRF-TOKEN": csrfToken } : {}),
...headers,
};
const response = await axiosInterceptorInstance
@ -115,8 +115,8 @@ export async function httpPutInterceptor(
};
const mergedHeaders = {
...defaultHeaders,
...headers,
...(csrfToken ? { "X-XSRF-TOKEN": csrfToken } : {}),
...headers,
};
const response = await axiosInterceptorInstance

View File

@ -255,18 +255,12 @@ export async function getUserNotifications(page = 0, typeId: any) {
export async function forgotPassword(username: any) {
const url = `forgot-password?username=${username}`;
const header = {
"content-Type": "application/json",
};
return httpPost(url, header);
return httpPost(url);
}
export async function saveUserReports(data: any) {
const url = "public/users/reports";
const header = {
"content-Type": "application/json",
};
return httpPost(url, header);
return httpPostInterceptor(url, data);
}
export async function listCarousel() {

View File

@ -8,7 +8,7 @@ export async function login(data: any) {
const headers = {
"content-type": "application/json",
};
return await httpPost(pathUrl, headers, data);
return await httpPost(pathUrl, data, headers);
}
export async function userInfo(token: any) {