Yes, I've tried other solutions I have found but to no avail. I've tried setting a variable (region) above the promise but realized that it'd be out of the scope so this was my next solution. Whenever I try to return region it comes back as undefined. Whenever I console.log it (in the same place) it works just fine. Any insight to this?
EDIT: iplocation is an npm package iplocation
function getRegion(ipAddr) {
iplocation(ipAddr)
.then(res => {
if (res.country == 'US') {
region = res.country + "-" + states[res.region_code];
} else {
region = res.country;
}
return region;
})
}