diff --git a/lib/utils.js b/lib/utils.js index aef5fa1..94477ed 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -169,19 +169,22 @@ function trim(str) { * * This allows axios to run in a web worker, and react-native. * Both environments support XMLHttpRequest, but not fully standard globals. + * As of react-native 0.13, it can be identified from navigator.product. * * web workers: * typeof window -> undefined * typeof document -> undefined * * react-native: - * typeof document.createElement -> undefined + * navigator.product -> 'ReactNative' */ function isStandardBrowserEnv() { + if (typeof navigator.product !== 'undefined' && navigator.product === 'ReactNative') { + return false; + } return ( typeof window !== 'undefined' && - typeof document !== 'undefined' && - typeof document.createElement === 'function' + typeof document !== 'undefined' ); }