Skip to content

Commit

Permalink
MWPW-143378 add safer error handling for geo2 service not working
Browse files Browse the repository at this point in the history
  • Loading branch information
vhargrave committed Sep 25, 2024
1 parent 1348319 commit c6947c8
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions express/scripts/utils/location-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ export async function getCountry(ignoreCookie = false) {
countryCode = sessionStorage.getItem('visitorCountry');
if (countryCode) return countryCode;

const resp = await fetch('https://geo2.adobe.com/json/');
if (resp.ok) {
const { country } = await resp.json();
const normalized = normCountry(country);
sessionStorage.setItem('visitorCountry', normalized);
return normalized;
try {
const resp = await fetch('https://geo2.adobe.com/json/');
if (resp.ok) {
const { country } = await resp.json();
const normalized = normCountry(country);
sessionStorage.setItem('visitorCountry', normalized);
return normalized;
}
} catch (e) {
window.lana.log('could not fet geo2 data from geo2 service', e);
}

const configCountry = getConfig().locale.region;
Expand Down

0 comments on commit c6947c8

Please sign in to comment.