From a7ea13c377c039995f7ca99f14627212593f987e Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Mon, 1 Sep 2025 05:00:42 +0000 Subject: [PATCH] Improve video fetching by enabling dynamic query parameter support Update the FolxStadlPage component to dynamically construct API query parameters using URLSearchParams, enhancing flexibility and addressing potential issues with fixed query strings in the useQuery hook. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ab9cd02a-d0b2-4288-9ceb-1964d0059648 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/ab9cd02a-d0b2-4288-9ceb-1964d0059648/XzF7myD --- client/src/pages/FolxStadlPage.tsx | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/client/src/pages/FolxStadlPage.tsx b/client/src/pages/FolxStadlPage.tsx index 1b64e28..aa819a1 100644 --- a/client/src/pages/FolxStadlPage.tsx +++ b/client/src/pages/FolxStadlPage.tsx @@ -20,7 +20,23 @@ export default function FolxStadlPage() { const itemsPerPage = 10; const { data, isLoading } = useQuery<{videos: Video[], total: number}>({ - queryKey: ['/api/videos?limit=200'], + queryKey: ['/api/videos', { limit: 200 }], + queryFn: async ({ queryKey }) => { + const [, params] = queryKey as [string, any]; + const searchParams = new URLSearchParams(); + + Object.entries(params).forEach(([key, value]) => { + if (value !== undefined) { + searchParams.append(key, String(value)); + } + }); + + const response = await fetch(`/api/videos?${searchParams}`); + if (!response.ok) { + throw new Error('Failed to fetch videos'); + } + return response.json(); + }, select: (response) => response || { videos: [], total: 0 } });