mirror of
https://github.com/tenrok/axios.git
synced 2026-06-20 20:00:40 +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:
committed by
Emily Morehouse
parent
961ecd129c
commit
0b3db5d87a
+5
-4
@@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) {
|
|||||||
|
|
||||||
function getDefaultAdapter() {
|
function getDefaultAdapter() {
|
||||||
var adapter;
|
var adapter;
|
||||||
if (typeof XMLHttpRequest !== 'undefined') {
|
// Only Node.JS has a process variable that is of [[Class]] process
|
||||||
// For browsers use XHR adapter
|
if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
|
||||||
adapter = require('./adapters/xhr');
|
|
||||||
} else if (typeof process !== 'undefined') {
|
|
||||||
// For node use HTTP adapter
|
// For node use HTTP adapter
|
||||||
adapter = require('./adapters/http');
|
adapter = require('./adapters/http');
|
||||||
|
} else if (typeof XMLHttpRequest !== 'undefined') {
|
||||||
|
// For browsers use XHR adapter
|
||||||
|
adapter = require('./adapters/xhr');
|
||||||
}
|
}
|
||||||
return adapter;
|
return adapter;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user