From ca42bb1d2a93d20c234eb1c9ab998aea062f83f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Holas?= Date: Mon, 13 Jul 2015 09:42:27 +0200 Subject: [PATCH] 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. --- lib/core/dispatchRequest.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/dispatchRequest.js b/lib/core/dispatchRequest.js index f063497..54db2e7 100644 --- a/lib/core/dispatchRequest.js +++ b/lib/core/dispatchRequest.js @@ -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