mirror of
https://github.com/ngthanhvu/kr-phim.git
synced 2026-08-10 16:07:47 +00:00
feat: implement pagination for comments with load more functionality
This commit is contained in:
@@ -34,14 +34,14 @@ export type Comment = {
|
||||
}
|
||||
|
||||
export function useComments() {
|
||||
async function fetchComments(source: string, slug: string, userId?: number) {
|
||||
async function fetchComments(source: string, slug: string, userId?: number, limit?: number, offset?: number) {
|
||||
try {
|
||||
const data = await $fetch('/api/comments', {
|
||||
query: { source, slug, userId },
|
||||
query: { source, slug, userId, limit, offset },
|
||||
})
|
||||
return data.items as Comment[]
|
||||
return data as { items: Comment[], total: number }
|
||||
} catch {
|
||||
return [] as Comment[]
|
||||
return { items: [] as Comment[], total: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user