Skip to content

Commit

Permalink
fix(useAxios): reset isAborted value on success (#3547)
Browse files Browse the repository at this point in the history
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
17359898647 and antfu committed Dec 4, 2023
1 parent 686884a commit 4b15938
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/integrations/useAxios/demo.vue
Expand Up @@ -2,7 +2,7 @@
import { stringify } from '@vueuse/docs-utils'
import { useAxios } from '.'
const { data, isLoading, isFinished, execute } = useAxios(
const { data, isLoading, isFinished, execute, abort, isAborted } = useAxios(
'https://jsonplaceholder.typicode.com/todos/1',
)
const text = stringify(data)
Expand All @@ -12,7 +12,11 @@ const text = stringify(data)
<button @click="execute()">
Execute
</button>
<button @click="abort()">
Abort
</button>
<note>Loading: {{ isLoading.toString() }}</note>
<note>Finished: {{ isFinished.toString() }}</note>
<note>Aborted: {{ isAborted.toString() }}</note>
<pre lang="yaml">{{ text }}</pre>
</template>
1 change: 1 addition & 0 deletions packages/integrations/useAxios/index.ts
Expand Up @@ -222,6 +222,7 @@ export function useAxios<T = any, R = AxiosResponse<T>, D = any>(...args: any[])

executeCounter += 1
const currentExecuteCounter = executeCounter
isAborted.value = false

instance(_url, { ...defaultConfig, ...typeof executeUrl === 'object' ? executeUrl : config, cancelToken: cancelToken.token })
.then((r: any) => {
Expand Down

0 comments on commit 4b15938

Please sign in to comment.