what3words / w3w-node-wrapper

Node wrapper for the What3Words API
https://docs.what3words.com/api/v3/
MIT License
45 stars 10 forks source link

[IN-316]: Update headers constant #64

Closed ghermet closed 1 year ago

ghermet commented 1 year ago

Problem

The Node Wrapper is currently not compatible with react native because it uses process.

 ERROR  TypeError: undefined is not a function, js engine: hermes

Fix

export const HEADERS = {
  'X-W3W-Wrapper':
    typeof window !== 'undefined'
      ? `what3words-JavaScript/${VERSION} (${window.navigator.userAgent})`
      : `what3words-Node/${VERSION} (Node ${process.version}; ${getPlatform(
          platform()
        )} ${release()})`,
};