2
0
mirror of https://github.com/tenrok/axios.git synced 2026-06-14 18:42:33 +03:00

Fixing defaults to use httpAdapter if available (#1285)

* Fixing defaults to use httpAdapter if available
* Use a safer, cross-platform method to detect the Node environment
This commit is contained in:
Tim Garthwaite
2018-04-11 11:23:38 -04:00
committed by Emily Morehouse
parent 961ecd129c
commit 0b3db5d87a
+5 -4
View File
@@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) {
function getDefaultAdapter() {
var adapter;
if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = require('./adapters/xhr');
} else if (typeof process !== 'undefined') {
// Only Node.JS has a process variable that is of [[Class]] process
if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
// For node use HTTP adapter
adapter = require('./adapters/http');
} else if (typeof XMLHttpRequest !== 'undefined') {
// For browsers use XHR adapter
adapter = require('./adapters/xhr');
}
return adapter;
}