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

[Bug] 'config' object reference changes between 'request' and 'response' interceptors #28

Open
KaKi87 opened this issue Sep 27, 2022 · 2 comments

Comments

@KaKi87
Copy link

KaKi87 commented Sep 27, 2022

const axiodOrAxios = typeof axiod !== 'undefined' ? axiod : typeof axios !== 'undefined' ? axios : undefined;

const client = axiodOrAxios.create({ baseURL: 'https://httpstat.us' });
let _config;
client.interceptors.request.use(config => {
    _config = config;
    return config;
});
client.interceptors.response.use(
    response => {
        console.log(_config === response.config);
        return response;
    },
    error => {
        console.log(_config === error.config);
        return Promise.reject(error);
    }
);
await client.get('/200');
await client.get('/401', { validateStatus: () => true });

Expected output (axios-like) :

true
true

Actual output :

false
false

Thanks

@roonie007
Copy link
Owner

roonie007 commented Oct 6, 2022

@KaKi87 can open a PR ?

@KaKi87
Copy link
Author

KaKi87 commented Oct 7, 2022

I am requesting this fix but am not qualified to do it myself, sorry.

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

No branches or pull requests

2 participants