The-Commit-Company / frappe-js-sdk

TypeScript/JavaScript library for Frappe REST API
MIT License
120 stars 43 forks source link

Check if `document` object is exist to understand better if the environment is browser or react native #26

Closed wethil closed 1 year ago

wethil commented 1 year ago

On the React Native, window global is exist but there is no location and hostname properties on that global, so typeof window !== 'undefined' checking is not working in React Native, and headers['X-Frappe-Site-Name'] = window.location.hostname; line throws error.

So I added another check as typeof document !== 'undefined' that understand better if it is browser or React Native environment