Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

loc.country = undefined "TypeError: Cannot read property 'iso_code' of undefined" #498

Open
pablolucas890 opened this issue Feb 8, 2023 · 0 comments

Comments

@pablolucas890
Copy link

pablolucas890 commented Feb 8, 2023

The normal loc object like with

loc : {                                                                                                                
  city: { geoname_id: 111111111, names: { en: 'XXXXXXXXXXXX' } },                                                       
  continent: {                                                                                                   
    code: 'SA',                                                                                                  
    geoname_id: 11111111,                                                                                         
    names: {                                                                                                     
      de: 'Südamerika',                                                                                          
      en: 'South America',                                                                                       
      es: 'Sudamérica',                                                                                          
      fr: 'Amérique du Sud',                                                                                     
      ja: '南アメリカ',                                                                                          
      'pt-BR': 'América do Sul',                                                                                 
      ru: 'Южная Америка',                                                                                       
      'zh-CN': '南美洲'                                                                                          
    }                                                                                                            
  },                                                                                                             
  country: {                                                                                                     
    geoname_id: 111111111,                                                                                         
    iso_code: 'BR',                                                                                              
    names: {                                                                                                     
      de: 'Brasilien',                                                                                           
      en: 'Brazil',                                                                                              
      es: 'Brasil',                                                                                              
      fr: 'Brésil',                                                                                              
      ja: 'ブラジル連邦共和国',                                                                                  
      'pt-BR': 'Brasil',                                                                                         
      ru: 'Бразилия',                                                                                            
      'zh-CN': '巴西'                                                                                            
    }                                                                                                            
  },                                                                                                             
  location: {                                                                                                    
    accuracy_radius: 100,
    latitude: 111111111111
    longitude: 111111111,
    time_zone: 'America/Sao_Paulo' 
  },
  postal: { code: '13250' },
  registered_country: {
    geoname_id: 111111111
    iso_code: 'BR',
    names: {
      de: 'Brasilien',
      en: 'Brazil',
      es: 'Brasil',
      fr: 'Brésil',
      ja: 'ブラジル連邦共和国',
      'pt-BR': 'Brasil',
      ru: 'Бразилия',
      'zh-CN': '巴西'
    }
  },
  subdivisions: [ { geoname_id: 1111111111, iso_code: 'SP', names: [Object] } ]
}

But one ovpn client return a object without some values:

loc : {
   registered_country: {
     geoname_id: 1111111,
     iso_code: 'BR',
     names: {
       de: 'Brasilien',
       en: 'Brazil',
       es: 'Brasil',
       fr: 'Brésil',
       ja: 'ブラジル連邦共和国',
       'pt-BR': 'Brasil',
       ru: 'Бразилия',
       'zh-CN': '巴西'
     }
   }
 }

Then we have a problem at this line:

client.country_code = loc.country.iso_code

To resolve for moment I write the iso_code, name, lat and lon with registered_country value or default, but it isn't apropriate for resolve the error...

image

I see that object its related with maxmid database, so the error can be related with this package or data

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant