mirror of
https://github.com/tenrok/axios.git
synced 2026-06-05 16:42:32 +03:00
In browsers check for XMLHttpRequest, not window
In nodejs testing environment it's possible to use https://github.com/tmpvar/jsdom library to define a window object, but you still want to use node http adapter. Due to those diverse testing environmnents, I propose to test for XMLHttpRequest directly, because window global object is not a sure sign of a browser environment anymore.
This commit is contained in:
@@ -11,7 +11,7 @@ module.exports = function dispatchRequest(config) {
|
||||
return new Promise(function (resolve, reject) {
|
||||
try {
|
||||
// For browsers use XHR adapter
|
||||
if (typeof window !== 'undefined') {
|
||||
if (typeof XMLHttpRequest !== 'undefined') {
|
||||
require('../adapters/xhr')(resolve, reject, config);
|
||||
}
|
||||
// For node use HTTP adapter
|
||||
|
||||
Reference in New Issue
Block a user