fix(useFetch): don't set isFetching to false when a request is aborted because of a refetch #3479
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Before submitting the PR, please make sure you do the following
fixes #123
).Description
Fixes #3300
Whenever a request is canceled because of a refetch,
isFetching
becomes incorrect because the aborted request sets it to false in thefinally
block.Additional context
I copied the solution from useAxios:
vueuse/packages/integrations/useAxios/index.ts
Lines 223 to 241 in aca6a79
🤖 Generated by Copilot at 5d7c249
Fixed a bug in
useFetch
that causedisFetching
to be inaccurate when multiple requests are made. Added a counter to track the latest request and ignore the previous ones.🤖 Generated by Copilot at 5d7c249
executeCounter
variable touseFetch
function to track the number of fetch requests (link, link)loading
function from settingisFetching
state to false when previous fetch requests are finished, by comparingcurrentExecuteCounter
withexecuteCounter
(link)