2
0
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:
Tomáš Holas
2015-07-13 09:42:27 +02:00
parent db85c7bf3a
commit ca42bb1d2a
+1 -1
View File
@@ -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