UNPKG

@betarena/ad-engine

Version:
69 lines (61 loc) 2.94 kB
// ╭──────────────────────────────────────────────────────────────────────────────────╮ // │ 📌 High Order Overview │ // ┣──────────────────────────────────────────────────────────────────────────────────┫ // │ ➤ Code Format // V.8.0 │ // │ ➤ Status // 🔒 LOCKED │ // │ ➤ Author(s) // @migbash │ // │ ➤ Maintainer(s) // @migbash │ // │ ➤ Created on // <date-created> │ // ┣──────────────────────────────────────────────────────────────────────────────────┫ // │ 📝 Description │ // ┣──────────────────────────────────────────────────────────────────────────────────┫ // │ BETARENA (Module) // │ |: Geo Location Logic // ╰──────────────────────────────────────────────────────────────────────────────────╯ // #region ➤ 📦 Package Imports import { logger } from './debug.js'; import type { GeoJsResponse } from '../types/geojs.js'; // #endregion ➤ 📦 Package Imports /** * @author * @migbash * @summary * 🟥 MAIN * @description * 📝 Detect user `geo-location`. * @return { Promise < GeoJsResponse > } * 📤 `geo-location` data. */ export async function getUserLocation ( ): Promise < GeoJsResponse > { const /** * @description * 📝 Response from `fetch` */ dataRes0 = await fetch ( 'https://get.geojs.io/v1/ip/geo.json', { method: 'GET' } ), /** * @description * 📝 Response from `fetch` */ dataRes1 = await dataRes0.json() ; // [🐞] logger ( [ `🔹 [var] ➤ dataRes0 :: ${JSON.stringify(dataRes1, null, 4)}`, '🚏 checkpoint ➤ getUserLocation(..) // END' ] ); return dataRes1; }