Skip to content

Commit

Permalink
Fixing defaults to use httpAdapter if available (axios#1285)
Browse files Browse the repository at this point in the history
* Fixing defaults to use httpAdapter if available
* Use a safer, cross-platform method to detect the Node environment
  • Loading branch information
Tim Garthwaite authored and emilyemorehouse committed Apr 11, 2018
1 parent 961ecd1 commit 0b3db5d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions lib/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 0b3db5d

Please sign in to comment.