Replies: 2 comments 6 replies
-
Why not use a wrapper over axios and add the timeout there. That's what I do in my projects at least. I use fetch and since my API has a specific structure (like always using problem details for non-2XX responses, see RFC 7807), I have a wrapper over fetch to handle all http response errors and client side errors like network issues in a unified way. In that wrapper I also include a custom delay. |
Beta Was this translation helpful? Give feedback.
-
While interceptors (read wrapper) are useful, they aren't the right place for granular control over loading times, especially considering background fetches. Also, if I moved the delay to interceptors or just to the service itself, it would limit reusability across different queries, as I wouldn't be able to easily customise the delay duration. Your proposal makes sense, but I value having control per query which this proposal promotes. |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I want to ensure a minimum loading time for API requests to:
Current Workarounds
Existing solutions usually involve custom modifications to the query function to artificially add a delay using
setTimeout
or delay operators. These workarounds require repetitive code within each query.Example usage:
Previous Discussions
This feature request, regarding its use with the useMutation hook, has been mentioned before but without a solution:
Is it possible to have a minimum loading time for useMutation hook? #5428
Proposed Solution
Add an optional minLoadingDuration parameter to query options, working as follows:
Example usage
Let me know if you'd like this proposal, want me to refine this further or help with a draft implementation.
Beta Was this translation helpful? Give feedback.
All reactions