Merge remote-tracking branch 'origin/main' into feature/140
This commit is contained in:
@@ -6,16 +6,29 @@ import { API_BASE_URL } from '@/config'
|
||||
import type { Post } from '@/types'
|
||||
|
||||
|
||||
export const fetchPosts = async ({ tags, match, limit, cursor }: {
|
||||
tags: string
|
||||
match: 'any' | 'all'
|
||||
limit: number
|
||||
cursor?: string }): Promise<{ posts: Post[]; nextCursor: string }> => {
|
||||
export const fetchPosts = async (
|
||||
{ tags, match, page, limit, cursor }: {
|
||||
tags: string
|
||||
match: 'any' | 'all'
|
||||
page?: number
|
||||
limit?: number
|
||||
cursor?: string }
|
||||
): Promise<{
|
||||
posts: Post[]
|
||||
count: number
|
||||
nextCursor: string }> => {
|
||||
const res = await axios.get (`${ API_BASE_URL }/posts`, {
|
||||
params: { tags, match, limit, ...(cursor && { cursor }) } })
|
||||
params: {
|
||||
tags,
|
||||
match,
|
||||
...(page && { page }),
|
||||
...(limit && { limit }),
|
||||
...(cursor && { cursor }) } })
|
||||
|
||||
return toCamel (res.data as any, { deep: true }) as { posts: Post[]
|
||||
nextCursor: string }
|
||||
return toCamel (res.data as any, { deep: true }) as {
|
||||
posts: Post[]
|
||||
count: number
|
||||
nextCursor: string }
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user