From 30d7250abf83868e88368a8d4ee18dd7bdb97074 Mon Sep 17 00:00:00 2001 From: Rama Priyanto Date: Sun, 25 May 2025 17:21:54 +0700 Subject: [PATCH] fix:service instance --- services/article.ts | 6 +++--- services/http-config/http-interceptor-services.ts | 8 ++++++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/services/article.ts b/services/article.ts index 0da8027..cfa473a 100644 --- a/services/article.ts +++ b/services/article.ts @@ -8,6 +8,7 @@ import { import Cookies from "js-cookie"; import { stat } from "fs"; import axiosInterceptorInstanceHumas from "./http-config/konten-humas-base-service"; +import { httpGetInterceptor } from "./http-config/http-interceptor-services"; const token = Cookies.get("access_token"); export async function getListArticle(props: PaginationRequest) { @@ -63,7 +64,7 @@ export async function getListArticleAdminPage(props: PaginationRequest) { "content-type": "application/json", Authorization: `Bearer ${token}`, }; - return await httpGet( + return await httpGetInterceptor( `/articles?sort=desc&sortBy=created_at&limit=${limit}&page=${page}&isPublish=${ isPublish === undefined ? "" : isPublish }&title=${search}&startDate=${startDate || ""}&endDate=${ @@ -72,8 +73,7 @@ export async function getListArticleAdminPage(props: PaginationRequest) { sort || "asc" }&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${ categoryIds || "" - }&createdByIds=${createdByIds || ""}`, - headers + }&createdByIds=${createdByIds || ""}` ); } diff --git a/services/http-config/http-interceptor-services.ts b/services/http-config/http-interceptor-services.ts index ff772b2..3fcd2ca 100644 --- a/services/http-config/http-interceptor-services.ts +++ b/services/http-config/http-interceptor-services.ts @@ -1,6 +1,6 @@ import { useRouter } from "next/navigation"; -import axiosInterceptorInstance from "./axios-interceptor-instance"; import Cookies from "js-cookie"; +import axiosInterceptorInstance from "./axios-interceptor-service"; export async function httpGetInterceptor(pathUrl: any) { const response = await axiosInterceptorInstance @@ -28,7 +28,11 @@ export async function httpGetInterceptor(pathUrl: any) { } } -export async function httpPostInterceptor(pathUrl: any, data: any, headers?: any) { +export async function httpPostInterceptor( + pathUrl: any, + data: any, + headers?: any +) { const response = await axiosInterceptorInstance .post(pathUrl, data, { headers }) .catch((error) => error.response);