UNPKG

barikoiapis

Version:

Bangladeshi location data provider API library from barikoi.com

32 lines 1.17 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.reverseGeocode = void 0; const config_1 = require("./config"); const axios_1 = __importDefault(require("axios")); async function reverseGeocode(options) { const apiKey = (0, config_1.getConfig)().apiKey; const version = (0, config_1.getConfig)().version; let apiUrl = ''; if (version === 'v2') { apiUrl = `https://barikoi.xyz/v2/api/search/reverse/geocode`; } else { apiUrl = `https://barikoi.xyz/v1/api/search/reverse/${apiKey}/geocode`; } const params = version === 'v1' ? { ...options } : { api_key: apiKey, ...options }; try { const response = await axios_1.default.get(apiUrl, { params, }); return response.data; // Return the full response.data } catch (error) { console.error('Reverse Geocode request failed:', error.message); throw error; } } exports.reverseGeocode = reverseGeocode; //# sourceMappingURL=reverseGeocode.js.map