Files
caszl-next/app/_services/articles.ts
quantulr 73ae2850b6 update
2023-11-08 17:19:55 +08:00

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);