T
TanStack3y ago
continuing-cyan

My function is not running completely. It's not running as expected

Can anybody tell me what am I doing wrong in this function?
2 Replies
continuing-cyan
continuing-cyanOP3y ago
const { data, isLoading, isFetching } = useQuery<Data<BrickType>>({
queryKey: ["bricks", filters],
queryFn: async ({queryKey}:any) => {
const {_, search,page,limit} = queryKey
let url = `http://localhost:5200/bricks?search=${search}&page=${page}&limit=${limit}`;
const res = await fetch(url);
const data = await res.json();
console.log(data)
return data;
},
refetchOnWindowFocus:false
});
const { data, isLoading, isFetching } = useQuery<Data<BrickType>>({
queryKey: ["bricks", filters],
queryFn: async ({queryKey}:any) => {
const {_, search,page,limit} = queryKey
let url = `http://localhost:5200/bricks?search=${search}&page=${page}&limit=${limit}`;
const res = await fetch(url);
const data = await res.json();
console.log(data)
return data;
},
refetchOnWindowFocus:false
});
I'm not able to dubbug the solution of it. Because the debugger is not going inside the function. That means the function is running but only the first line of the function other variables inside of it is not runnig. 🤷‍♂️
conscious-sapphire
conscious-sapphire3y ago
Your queryKey is an array, yet you destruct it like an object Removing the :any will likely surface this issue

Did you find this page helpful?