You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, axios uses the following code to choose between the XHR and Node.js adapters:
functiongetDefaultAdapter(){varadapter;if(typeofXMLHttpRequest!=='undefined'){// For browsers use XHR adapteradapter=require('./adapters/xhr');}elseif(typeofprocess!=='undefined'){// For node use HTTP adapteradapter=require('./adapters/http');}returnadapter;}
You can override the default behavior using the adapter config option as follows:
axios.defaults.adapter=function(){returnrequire('axios/adapters/http');// always use Node.js adapter};
i'm getting this error
"adapter(...).then is not a function"
i'm using
var axios = require('axios');
axios.defaults.adapter = function() {
return require('axios/lib/adapters/http'); // always use Node.js adapter
};
The solution doesn't work for me.
Still getting The provided value 'stream' is not a valid enum value of type XMLHttpRequestResponseType. Uncaught (in promise) TypeError: data.pipe is not a function
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = require('./adapters/xhr');
} else if (typeof process !== 'undefined') {
// For node use HTTP adapter
adapter = require('./adapters/http'); // <- Webpack replace this by `adapter = require('./adapters/xhr');`
}
return adapter;
}
I ended up forking this repos, removing the browser property in the package.json.
Activity
nickuraltsev commentedon Nov 25, 2016
By default, axios uses the following code to choose between the XHR and Node.js adapters:
You can override the default behavior using the
adapterconfig option as follows:Hope this helps!
paul-piro commentedon Dec 14, 2016
i'm getting this error
"adapter(...).then is not a function"
i'm using
var axios = require('axios');
axios.defaults.adapter = function() {
return require('axios/lib/adapters/http'); // always use Node.js adapter
};
paul-piro commentedon Dec 14, 2016
Solved:
axios.defaults.adapter = require('axios/lib/adapters/http');
ozalto commentedon Feb 27, 2020
This line was a life-saver :)
muscaiu commentedon Mar 9, 2020
The solution doesn't work for me.
Still getting
The provided value 'stream' is not a valid enum value of type XMLHttpRequestResponseType.Uncaught (in promise) TypeError: data.pipe is not a functionANG95 commentedon Mar 14, 2020
esto funcionó para mi Axios.defaults.adapter = require('axios/lib/adapters/http');
ArnaudValensi commentedon Mar 26, 2020
The problem is in the
package.jsonof this repository:This makes webpack replace the http adapter:
I ended up forking this repos, removing the
browserproperty in thepackage.json.Then
We still have to replace the adapter because the first condition of
getDefaultAdapter()is still true :davide-sergi commentedon May 12, 2020
Is it possible to adapt Axios on top of electron chromium stack?