iso3166-1 icon indicating copy to clipboard operation
iso3166-1 copied to clipboard

Cannot read property 'alpha2' of undefined

Open Vadorequest opened this issue 4 years ago • 1 comments

Trying the basic example in my app, it works fine with to3() but fails with to2().

Cannot read property 'alpha2' of undefined

TypeError: Cannot read property 'alpha2' of undefined
    at Object.b [as to2] (/Users/vadorequest/dev/loan-advisor/node_modules/iso3166-1/dist/iso3166-1.js:3:11181)
    at Object../hoc/withData.js (/Users/vadorequest/dev/loan-advisor/hoc/withData.js:16:5)
    at __webpack_require__ (/Users/vadorequest/dev/loan-advisor/.next/dist/bundles/pages/webpack/bootstrap b368674930c3372dd65a:21:1)
    at Object../pages/school/index.js (/Users/vadorequest/dev/loan-advisor/pages/school/index.js:18:1)
    at __webpack_require__ (/Users/vadorequest/dev/loan-advisor/.next/dist/bundles/pages/webpack/bootstrap b368674930c3372dd65a:21:1)
    at Object.2 (/Users/vadorequest/dev/loan-advisor/.next/dist/bundles/pages/school.js:3556:18)
    at __webpack_require__ (/Users/vadorequest/dev/loan-advisor/.next/dist/bundles/pages/webpack/bootstrap b368674930c3372dd65a:21:1)
    at module.exports../components/Bloc.js.Object.defineProperty.value (/Users/vadorequest/dev/loan-advisor/.next/dist/bundles/pages/webpack/bootstrap b368674930c3372dd65a:68:1)
    at Object.<anonymous> (/Users/vadorequest/dev/loan-advisor/.next/dist/bundles/pages/school.js:73:10)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)

With the following source code:

import locale2 from 'locale2';
import iso3166 from 'iso3166-1';

console.log(locale2)
console.log(iso3166.fromLocale(locale2))
console.log(iso3166.fromLocale(locale2).to2())

Here is what I get with to3() image

Tested on both Chrome latest and Firefox, same result

Vadorequest avatar Sep 05 '19 17:09 Vadorequest

I opened a PR. The reason why it failed is still unknown to me, the tests are passing properly on my machine with the same example (en-US), I really don't get it. Maybe some race condition related to the bundle, compilation, minification, etc.

Vadorequest avatar Sep 05 '19 19:09 Vadorequest