36 lines
821 B
TypeScript
36 lines
821 B
TypeScript
import { PageData } from "@/app/_types/base";
|
|
import {
|
|
Article,
|
|
ArticleDetail,
|
|
ArticleDetailParams,
|
|
ArticleListParams,
|
|
} from "@/app/_types/article";
|
|
|
|
export const listArticles = (
|
|
params: ArticleListParams,
|
|
): Promise<PageData<Article>> =>
|
|
fetch(
|
|
`${process.env.NEXT_PUBLIC_BASE_URL}/article/list?${new URLSearchParams(
|
|
params as Record<string, any>,
|
|
)}`,
|
|
{
|
|
cache: "no-store",
|
|
},
|
|
)
|
|
.then((res) => res.json())
|
|
.then((json) => json.data);
|
|
|
|
export const articleDetail = (
|
|
params: ArticleDetailParams,
|
|
): Promise<ArticleDetail> =>
|
|
fetch(
|
|
`${process.env.NEXT_PUBLIC_BASE_URL}/pc/articleDetail?${new URLSearchParams(
|
|
params as Record<string, any>,
|
|
)}`,
|
|
{
|
|
cache: "no-store",
|
|
},
|
|
)
|
|
.then((res) => res.json())
|
|
.then((json) => json.data);
|