fix:service instance
This commit is contained in:
parent
e5a7990af0
commit
30d7250abf
|
|
@ -8,6 +8,7 @@ import {
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
import { stat } from "fs";
|
import { stat } from "fs";
|
||||||
import axiosInterceptorInstanceHumas from "./http-config/konten-humas-base-service";
|
import axiosInterceptorInstanceHumas from "./http-config/konten-humas-base-service";
|
||||||
|
import { httpGetInterceptor } from "./http-config/http-interceptor-services";
|
||||||
|
|
||||||
const token = Cookies.get("access_token");
|
const token = Cookies.get("access_token");
|
||||||
export async function getListArticle(props: PaginationRequest) {
|
export async function getListArticle(props: PaginationRequest) {
|
||||||
|
|
@ -63,7 +64,7 @@ export async function getListArticleAdminPage(props: PaginationRequest) {
|
||||||
"content-type": "application/json",
|
"content-type": "application/json",
|
||||||
Authorization: `Bearer ${token}`,
|
Authorization: `Bearer ${token}`,
|
||||||
};
|
};
|
||||||
return await httpGet(
|
return await httpGetInterceptor(
|
||||||
`/articles?sort=desc&sortBy=created_at&limit=${limit}&page=${page}&isPublish=${
|
`/articles?sort=desc&sortBy=created_at&limit=${limit}&page=${page}&isPublish=${
|
||||||
isPublish === undefined ? "" : isPublish
|
isPublish === undefined ? "" : isPublish
|
||||||
}&title=${search}&startDate=${startDate || ""}&endDate=${
|
}&title=${search}&startDate=${startDate || ""}&endDate=${
|
||||||
|
|
@ -72,8 +73,7 @@ export async function getListArticleAdminPage(props: PaginationRequest) {
|
||||||
sort || "asc"
|
sort || "asc"
|
||||||
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
|
}&category=${categorySlug || ""}&isBanner=${isBanner || ""}&categoryIds=${
|
||||||
categoryIds || ""
|
categoryIds || ""
|
||||||
}&createdByIds=${createdByIds || ""}`,
|
}&createdByIds=${createdByIds || ""}`
|
||||||
headers
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import axiosInterceptorInstance from "./axios-interceptor-instance";
|
|
||||||
import Cookies from "js-cookie";
|
import Cookies from "js-cookie";
|
||||||
|
import axiosInterceptorInstance from "./axios-interceptor-service";
|
||||||
|
|
||||||
export async function httpGetInterceptor(pathUrl: any) {
|
export async function httpGetInterceptor(pathUrl: any) {
|
||||||
const response = await axiosInterceptorInstance
|
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
|
const response = await axiosInterceptorInstance
|
||||||
.post(pathUrl, data, { headers })
|
.post(pathUrl, data, { headers })
|
||||||
.catch((error) => error.response);
|
.catch((error) => error.response);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue