@arcteryx/js-geolocation

ARCTERYX JavaScript library to get the geolocation for a user by calling the /api/geolocation from the edge in Fastly. It will save the geoLocation information in localStorage under "geolocation" key. It will return the geoLocation from localStorage if it exists. If it's been stored in localStorage for more than 1hr it will fetch it again and store it.

Usage no npm install needed!

<script type="module">
  import arcteryxJsGeolocation from 'https://cdn.skypack.dev/@arcteryx/js-geolocation';
</script>

README

Arc'teryx Geolocation Library

ARCTERYX JavaScript library to get the geolocation for a user by calling the /api/geolocation from the edge in Fastly. It will save the geoLocation information in localStorage under "geolocation" key. It will return the geoLocation from localStorage if it exists. If it's been stored in localStorage for more than 1hr it will fetch it again and store it.

Usage

npm install @arcteryx/js-geolocation

const geoLocation = await getGeolocation();

geoLocation =  {
  city: "vancouver",
  region: "BC",
  country_code: "CA",
  country_name: "canada",
  postalcode: "v5y 1e6",
  latitude: "49.270",
  longitude: "-123.110",
  saveAt: "2020-12-17T11:42:12.803Z"
}

Build and test locally

npm ci
npm run build