From ae8d458126b3df54ce038ef8d13038768afac28e Mon Sep 17 00:00:00 2001 From: Nisarg Date: Mon, 11 Oct 2021 10:53:24 -0700 Subject: [PATCH] fixed issue --- lib/request.js | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/lib/request.js b/lib/request.js index f88d6b54..02dabb1d 100644 --- a/lib/request.js +++ b/lib/request.js @@ -60,28 +60,18 @@ export async function getLocation(req, ip) { } const result = await geoip.lookup(ip); - console.log(result); - if (Array.isArray(result)) { - return { - country: result[0]?.country, - region: result[0]?.region, - city: result[0]?.city, - }; - } else { - return { - country: result?.country, - region: result?.region, - city: result?.city, - }; - } + + return { + country: result?.country, + region: result?.region, + city: result?.city, + }; } export async function getClientInfo(req, { screen }) { const userAgent = req.headers['user-agent']; const ip = getIpAddress(req); - const country = await getLocation(req, ip).country; - const region = await getLocation(req, ip).region; - const city = await getLocation(req, ip).city; + const { country, region, city } = await getLocation(req, ip); const browser = browserName(userAgent); const os = detectOS(userAgent); const device = getDevice(screen, browser, os);