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

adapter no run #386

Open
crazyair opened this issue Jul 31, 2024 · 1 comment
Open

adapter no run #386

crazyair opened this issue Jul 31, 2024 · 1 comment

Comments

@crazyair
Copy link

import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';

const instance = axios.create({
    adapter: config => {
        console.log('no run');
        return axios({ ...config, adapter: undefined });
    },
});

const mock = new MockAdapter(instance);

mock.onGet('/users').reply(config => {
    return new Promise(resolve => {
        setTimeout(() => {
            resolve([200, { timeout: config.timeout }]);
        }, config.timeout);
    });
});

instance.get('/users').then(data => {
    console.log('data', data);
});
@marcbachmann
Copy link
Collaborator

What's the question here?
console.log('no run'); isn't logged. The adapter never gets called as it gets mocked with new MockAdapter(instance)

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