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

useAxios,execute After the request is sent, the returned data is printed as old data (probabilistic) #2392

Closed
7 tasks done
laterdays opened this issue Nov 2, 2022 · 7 comments · Fixed by #2728
Closed
7 tasks done

Comments

@laterdays
Copy link

Describe the bug

After the request is sent, the data returned is up-to-date when viewed by network, but the data printed as data.value is old
(probabilistic)

const { excute } = useAxios('api');

const test = async () => {
  const { data } = await excute(__, {}, { params: { id: 1 } });
  console.log(data);
};

Reproduction

System Info

windows

Used Package Manager

yarn

Validations

@ethansnow2012
Copy link
Contributor

I got the issue too. In vueuse ^9.1.0, axios ^0.27.2.

@laterdays
Copy link
Author

@antfu

@laterdays
Copy link
Author

@antfu Looking forward to resolution

@ethansnow2012
Copy link
Contributor

After I have deeper understanding, I figured out in my case it may not be a bug. It's just that I sent two requests
in order but the first one was received later than the second one. Thus the first one request overwrite the second.

To properly receive the second without being overwrite, I would like to abort to first one. But if I understand "useAxios" properly, there is no straightforward way to do it.(?

Here is how I tried to abort it(with no success).

let { data, execute, abort } = useAxios(
        'xxxxx',
        {
            method: 'POST',
            data: xxxxx1
        },
        { immediate: false }
    )
    watchThrottled(
        () => xxxxxx, //some trigger
        () => {
            abort() // this will abort all future execution
            execute('xxxx', { data: xxx_some_condition_xxxx })
        },
        { throttle: 600 },
    )

Thanks for any help in advance.

@laterdays
Copy link
Author

@antfu Can it be solved?

@stale
Copy link

stale bot commented Jan 21, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jan 21, 2023
@stale stale bot closed this as completed Jan 28, 2023
@Alfred-Skyblue
Copy link
Member

Alfred-Skyblue commented Feb 15, 2023

resolved #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.

3 participants