async function getNearestRegion()

in agent-app/src/containers/MeetingForm/RegionSelection.js [19:42]


    async function getNearestRegion() {
      if (region) {
        return;
      }

      try {
        const res = await fetch(`https://nearest-media-region.l.chime.aws`, {
          method: 'GET'
        });

        if (!res.ok) {
          throw new Error('Server error');
        }

        const data = await res.json();
        const nearestRegion = data.region;

        if (mounted) {
          setRegion((region) => region || nearestRegion);
        }
      } catch (e) {
        console.error('[VideoCallEscalation] Could not fetch nearest region: ', e.message);
      }
    }