fixed issue

pull/885/head
Nisarg 2021-10-11 10:53:24 -07:00
parent 2e535d86c7
commit ae8d458126
1 changed files with 7 additions and 17 deletions

View File

@ -60,28 +60,18 @@ export async function getLocation(req, ip) {
} }
const result = await geoip.lookup(ip); const result = await geoip.lookup(ip);
console.log(result);
if (Array.isArray(result)) { return {
return { country: result?.country,
country: result[0]?.country, region: result?.region,
region: result[0]?.region, city: result?.city,
city: result[0]?.city, };
};
} else {
return {
country: result?.country,
region: result?.region,
city: result?.city,
};
}
} }
export async function getClientInfo(req, { screen }) { export async function getClientInfo(req, { screen }) {
const userAgent = req.headers['user-agent']; const userAgent = req.headers['user-agent'];
const ip = getIpAddress(req); const ip = getIpAddress(req);
const country = await getLocation(req, ip).country; const { country, region, city } = await getLocation(req, ip);
const region = await getLocation(req, ip).region;
const city = await getLocation(req, ip).city;
const browser = browserName(userAgent); const browser = browserName(userAgent);
const os = detectOS(userAgent); const os = detectOS(userAgent);
const device = getDevice(screen, browser, os); const device = getDevice(screen, browser, os);