feat: fixing http service & config
This commit is contained in:
parent
47402ea655
commit
bee5dcadb6
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue