maybe geoip is an array
parent
065984f8f7
commit
2e535d86c7
|
@ -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 }) {
|
||||
|
|
Loading…
Reference in New Issue