This commit is contained in:
35
src/lib/apis/legacy/blog.ts
Normal file
35
src/lib/apis/legacy/blog.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import { legacyClient } from '../clients'
|
||||
|
||||
export const listBlogs = async ({
|
||||
page = 1,
|
||||
limit = 20,
|
||||
}: {
|
||||
page?: number
|
||||
limit?: number
|
||||
}) => {
|
||||
const resp = await legacyClient.post('/v1/blog/list', { page, limit })
|
||||
return resp.data.data as {
|
||||
id: number
|
||||
title: string
|
||||
featured_image: null | {
|
||||
image_url: string
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
export const getBlog: (
|
||||
blog_id: number,
|
||||
) => Promise<null | { title: string; content: string }> = async (
|
||||
blog_id: number,
|
||||
) => {
|
||||
const resp = await legacyClient.get(`/v1/blog/${blog_id}`, {
|
||||
validateStatus: (status) => status == 200 || status == 404,
|
||||
})
|
||||
if (resp.status == 404) {
|
||||
return null
|
||||
}
|
||||
return resp.data as {
|
||||
title: string
|
||||
content: string
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user