Files
caszl-next/app/_services/articles.ts

36 lines
821 B
TypeScript
Raw Normal View History

2023-11-08 17:19:55 +08:00
import { PageData } from "@/app/_types/base";
2023-10-27 17:29:50 +08:00
import {
Article,
ArticleDetail,
ArticleDetailParams,
ArticleListParams,
2023-11-06 17:27:50 +08:00
} from "@/app/_types/article";
2023-10-27 17:29:50 +08:00
2023-11-08 17:19:55 +08:00
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);
2023-10-27 17:29:50 +08:00
2023-11-08 17:19:55 +08:00
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);