Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(useAxios): reset isAborted value on success #3547

Merged
merged 11 commits into from
Dec 4, 2023
6 changes: 5 additions & 1 deletion packages/integrations/useAxios/demo.vue
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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