Skip to content

Commit 0b3db5d

Browse files
Tim Garthwaiteemilyemorehouse
authored andcommitted
Fixing defaults to use httpAdapter if available (axios#1285)
* Fixing defaults to use httpAdapter if available * Use a safer, cross-platform method to detect the Node environment
1 parent 961ecd1 commit 0b3db5d

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

lib/defaults.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ function setContentTypeIfUnset(headers, value) {
1515

1616
function getDefaultAdapter() {
1717
var adapter;
18-
if (typeof XMLHttpRequest !== 'undefined') {
19-
// For browsers use XHR adapter
20-
adapter = require('./adapters/xhr');
21-
} else if (typeof process !== 'undefined') {
18+
// Only Node.JS has a process variable that is of [[Class]] process
19+
if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
2220
// For node use HTTP adapter
2321
adapter = require('./adapters/http');
22+
} else if (typeof XMLHttpRequest !== 'undefined') {
23+
// For browsers use XHR adapter
24+
adapter = require('./adapters/xhr');
2425
}
2526
return adapter;
2627
}

0 commit comments

Comments
 (0)