完成BlogApi
This commit is contained in:
11
tone-page-web/lib/api/blog/get.ts
Normal file
11
tone-page-web/lib/api/blog/get.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function get(id: string) {
|
||||
return fetcher<{
|
||||
id: string;
|
||||
title: string;
|
||||
createdAt: string;
|
||||
content: string;
|
||||
}>(`/api/blog/${id}`);
|
||||
}
|
||||
2
tone-page-web/lib/api/blog/index.ts
Normal file
2
tone-page-web/lib/api/blog/index.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export * from './list';
|
||||
export * from './get';
|
||||
6
tone-page-web/lib/api/blog/list.ts
Normal file
6
tone-page-web/lib/api/blog/list.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import { Blog } from "@/lib/types/blog";
|
||||
import fetcher from "../fetcher";
|
||||
|
||||
export async function list() {
|
||||
return fetcher<Blog[]>('/api/blog');
|
||||
}
|
||||
Reference in New Issue
Block a user