This repository has been archived on 2023-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
current-kwh-cost/node_modules/axios/lib/platform/browser/index.js
2022-11-17 16:42:35 +00:00

44 lines
1.0 KiB
JavaScript

import URLSearchParams from './classes/URLSearchParams.js'
import FormData from './classes/FormData.js'
/**
* Determine if we're running in a standard browser environment
*
* This allows axios to run in a web worker, and react-native.
* Both environments support XMLHttpRequest, but not fully standard globals.
*
* web workers:
* typeof window -> undefined
* typeof document -> undefined
*
* react-native:
* navigator.product -> 'ReactNative'
* nativescript
* navigator.product -> 'NativeScript' or 'NS'
*
* @returns {boolean}
*/
const isStandardBrowserEnv = (() => {
let product;
if (typeof navigator !== 'undefined' && (
(product = navigator.product) === 'ReactNative' ||
product === 'NativeScript' ||
product === 'NS')
) {
return false;
}
return typeof window !== 'undefined' && typeof document !== 'undefined';
})();
export default {
isBrowser: true,
classes: {
URLSearchParams,
FormData,
Blob
},
isStandardBrowserEnv,
protocols: ['http', 'https', 'file', 'blob', 'url', 'data']
};