fix(island): 🐛 replace old hard coded fetch endpoint
This commit is contained in:
parent
80ad700c4c
commit
759bb90e18
|
@ -20,7 +20,7 @@ export type CardListProps<ApiResponse, RefType = null> = {
|
|||
}
|
||||
|
||||
export default function CardList<ApiResponse, RefType = null>(
|
||||
{ limit, builder, ...props }: CardListProps<ApiResponse, RefType>,
|
||||
{ limit, builder, apiRoute, ...props }: CardListProps<ApiResponse, RefType>,
|
||||
) {
|
||||
const list: Signal<JSX.Element[]> = useSignal<JSX.Element[]>([])
|
||||
const ac = new AbortController()
|
||||
|
@ -34,7 +34,7 @@ export default function CardList<ApiResponse, RefType = null>(
|
|||
if (ref.current && useObserver) {
|
||||
const observer = new IntersectionObserver(([entry]) => {
|
||||
if (entry.isIntersecting) {
|
||||
fillList(list, builder, { limit, ac })
|
||||
fillList(list, builder, apiRoute, { limit, ac })
|
||||
observer.disconnect()
|
||||
}
|
||||
}, {
|
||||
|
@ -42,7 +42,7 @@ export default function CardList<ApiResponse, RefType = null>(
|
|||
})
|
||||
observer.observe(ref.current)
|
||||
} else {
|
||||
fillList(list, builder, { limit, ac })
|
||||
fillList(list, builder, apiRoute, { limit, ac })
|
||||
}
|
||||
})
|
||||
|
||||
|
@ -67,11 +67,12 @@ export default function CardList<ApiResponse, RefType = null>(
|
|||
function fillList<ApiResponse>(
|
||||
list: Signal<JSX.Element[]>,
|
||||
builder: Builder<ApiResponse>,
|
||||
apiRoute: string,
|
||||
{ limit, ac }: { limit?: number; ac?: AbortController },
|
||||
) {
|
||||
;(async () => {
|
||||
const propsList = requestApiStream<void, ApiResponse>(
|
||||
'news/fetchAll',
|
||||
apiRoute,
|
||||
'GET',
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in a new issue