maybe geoip is an array
parent
065984f8f7
commit
2e535d86c7
|
@ -61,13 +61,20 @@ export async function getLocation(req, ip) {
|
||||||
|
|
||||||
const result = await geoip.lookup(ip);
|
const result = await geoip.lookup(ip);
|
||||||
console.log(result);
|
console.log(result);
|
||||||
|
if (Array.isArray(result)) {
|
||||||
|
return {
|
||||||
|
country: result[0]?.country,
|
||||||
|
region: result[0]?.region,
|
||||||
|
city: result[0]?.city,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
return {
|
return {
|
||||||
country: result?.country,
|
country: result?.country,
|
||||||
region: result?.region,
|
region: result?.region,
|
||||||
city: result?.city,
|
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'];
|
||||||
|
|
Loading…
Reference in New Issue