UNPKG

barikoiapis

Version:

Bangladeshi location data provider API library from barikoi.com

33 lines 1.21 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.nearby = void 0; const axios_1 = __importDefault(require("axios")); const config_1 = require("./config"); async function nearby(radius, limit, options) { // Adjust the return type if needed 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/nearby/${radius}/${limit}`; } else { apiUrl = `https://barikoi.xyz/v1/api/search/nearby/${apiKey}/${radius}/${limit}`; } const params = version === 'v1' ? { ...options } : { api_key: apiKey, ...options }; try { const response = await axios_1.default.get(apiUrl, { params, }); return response.data; // Return the entire response data } catch (error) { console.error('Nearby places request failed:', error.message); throw error; } } exports.nearby = nearby; //# sourceMappingURL=nearby.js.map