fix(island): 🐛 replace old hard coded fetch endpoint

This commit is contained in:
Julien Oculi 2024-07-10 17:46:22 +02:00
parent 80ad700c4c
commit 759bb90e18

View file

@ -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',
)