maybe geoip is an array

pull/885/head
Nisarg 2021-10-11 10:38:05 -07:00
parent 065984f8f7
commit 2e535d86c7
1 changed files with 13 additions and 6 deletions

View File

@ -61,12 +61,19 @@ export async function getLocation(req, ip) {
const result = await geoip.lookup(ip);
console.log(result);
return {
country: result?.country,
region: result?.region,
city: result?.city,
};
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 }) {