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
Refactored adapters loader; #5277
Conversation
Does this change apply to defaults as well, like:
|
Yes, the adapter is resolved right before its call. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Is that possible to export method import axios, { getAdapter } from 'axios';
const defaultAdapters = axios.defaults.adapter;
axios.defaults.adapter = (config) => {
// do something
const adapter = getAdapter(defaultAdapters);
adapter(config);
// do something
} |
This was added with nock#1711 but [has changed with axios v1](axios/axios#5277)
* fix(README): Update axios example This was added with #1711 but [has changed with axios v1](axios/axios#5277)
I want to do adapter enhancement, why not expose the adapter |
* fix(deps): update dependency axios to v1 * Use new adapter setting See axios/axios#5277 * Fix tests * Remove unnecessary transform --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Brendan Mulholland <brendan@recital.software>
* fix(deps): update dependency axios to v1 * Use new adapter setting See axios/axios#5277 * Fix tests * Remove unnecessary transform * chore(deps): Remove history dependency * chore: update tests to remove `history` --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Afonso Jorge Ramos <afonsojorgeramos@gmail.com>
Now we can set the adapter by name:
We can use auto-select from the list (If the adapter is not supported its handle is set to false and Axios tries to set the next one):
So now the default adapter config is
adapter: ['xhr', 'http']
;In the future, when we have more than 2 adapters (fetch, http2, other frameworks/OS), we will be able to make separate builds with the selected adapters, and this adapter loader will deal with this by selecting the next available adapter or throwing an error like:
Closes #5264;
Closes #5263;