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);
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,
};
}
}
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);