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

With useAxios, it cannot use execute after it has been aborted. #2697

Closed
7 tasks done
pieterwouda opened this issue Jan 29, 2023 · 1 comment · Fixed by #2728
Closed
7 tasks done

With useAxios, it cannot use execute after it has been aborted. #2697

pieterwouda opened this issue Jan 29, 2023 · 1 comment · Fixed by #2728

Comments

@pieterwouda
Copy link

Describe the bug

Using execute from useAxios will stop working after a request has been aborted.
Similar implementation with useFetch will just work fine.

import { useFetch } from '@vueuse/core';
import { useAxios } from '@vueuse/integrations/useAxios';

const {
  data: fetchData,
  execute: fetchExecute,
  abort: fetchAbort,
} = useFetch('https://reqres.in/api/users/2?delay=2', {}, { immediate: false });

const {
  data: axiosData,
  execute: axiosExecute,
  abort: axiosAbort,
} = useAxios('https://reqres.in/api/users/2?delay=2', {}, { immediate: false });

function getDataWithFetch() {
  fetchAbort(); // Abort current request.
  fetchExecute(); // Still works after being aborted.
}

function getDataWithAxios() {
  axiosAbort(); // Abort current request.
  axiosExecute(); // Doesn't work anymore after being aborted.
}

Reproduction

https://stackblitz.com/edit/vitejs-vite-xpwc3e/?file=src%2FApp.vue

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (16) x64 AMD Ryzen 7 PRO 4750U with Radeon Graphics
    Memory: 16.03 GB / 31.23 GB
  Binaries:
    Node: 18.13.0 - C:\Program Files\nodejs\node.EXE        
    npm: 8.19.3 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Spartan (44.19041.1266.0), Chromium (108.0.1462.76)
    Internet Explorer: 11.0.19041.1566
  npmPackages:
    @vueuse/core: ^9.12.0 => 9.12.0
    @vueuse/integrations: ^9.12.0 => 9.12.0
    vue: ^3.2.45 => 3.2.45

Used Package Manager

npm

Validations

@Alfred-Skyblue
Copy link
Member

Resolved in PR #2728

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants