add optional check for subdivision

This commit is contained in:
Francis Cao 2023-08-30 09:52:24 -07:00
parent 69410f4a55
commit 50b4ac9889

View File

@ -71,7 +71,7 @@ export async function getLocation(ip, req) {
return {
country,
subdivision1: subdivision1.includes('-') ? subdivision1 : `${country}-${subdivision1}`,
subdivision1: subdivision1?.includes('-') ? subdivision1 : `${country}-${subdivision1}`,
city,
};
}
@ -84,7 +84,7 @@ export async function getLocation(ip, req) {
return {
country,
subdivision1: subdivision1.includes('-') ? subdivision1 : `${country}-${subdivision1}`,
subdivision1: subdivision1?.includes('-') ? subdivision1 : `${country}-${subdivision1}`,
city,
};
}