T
TanStack10mo ago
genetic-orange

How to pass timeout option to useQuery using fetch from context signal in the below code.

const query = useQuery({queryKey: [key], queryFn: ({signal}) => fetch(url, {signal})})
const query = useQuery({queryKey: [key], queryFn: ({signal}) => fetch(url, {signal})})
2 Replies
optimistic-gold
optimistic-gold10mo ago
TanStack | High Quality Open-Source Software for Web Developers
Headless, type-safe, powerful utilities for complex workflows like Data Management, Data Visualization, Charts, Tables, and UI Components.
From An unknown user
From An unknown user
optimistic-gold
optimistic-gold10mo ago
To expand on that, you can't, but you can use cancelQueries if you want to abort a fetch. If you use a fetching lib like axios/ky which have timeouts built in, RQ will know the promise was rejected and act accordingly. You don't need to do anything special there.

Did you find this page helpful?