konsalex / Airport-Autocomplete-JS

Airport Autocomplete Input tag
MIT License
31 stars 18 forks source link

Error: Undefined is not an object (evaluating 'r[0]') #13

Closed CodeByFlo closed 3 years ago

CodeByFlo commented 3 years ago

Hi konsalex,

I had quite an implementation working for a long time that is important to my organization, but suddenly it stopped working (without changing anything is far as I know). There aren't any suggestions coming back when you type a name and I get the error in the console on line 2876, 2850 and 5836 of index.browser.min.js: undefined is not an object (evaluating 'r[0]') and in Chrome it says:

index.browser.min.js?ver=1:10 Uncaught TypeError: Cannot read property '0' of undefined at t.value (index.browser.min.js?ver=1:10) at t.value (index.browser.min.js?ver=1:10) at HTMLInputElement.y (index.browser.min.js?ver=1:10)

Do you have any idea what could be the issue here? It would be great if we could sort it out, since people are dependent on it. If you want to see a page where it is in action: https://alivetoearth.nl/product/compenseer-je-vlucht/ (my coding isn't great but is worked for a long time)

CodeByFlo commented 3 years ago

Even when I try the demo (so nothing on my website), this error pops up.

konsalex commented 3 years ago

Hey @meeuwsen I am sorry to hear that and for the confusion.

Are you importing via NPM or with the CDN directly to the website?

That will help me debug the issue.

CodeByFlo commented 3 years ago

Hi @konsalex Thank you for helping! I just add it to functions.php in Wordpress like so and I use Cloudflare as a cdn :

wp_enqueue_script( 'index.browser.min.js', 'https://cdn.jsdelivr.net/npm/airport-autocomplete-js@2.0.3/dist/index.browser.min.js', '', 1, true);

I know some coding, but I am not so good yet with best practices, so if there is a better way I would love to know.

konsalex commented 3 years ago

Hey @meeuwsen .

Change the source of script to https://cdn.jsdelivr.net/npm/airport-autocomplete-js@2.1.4/dist/index.browser.min.js

The Fuse.js made a huge change in the initialisation of the Object. Seems weird though cause you are using an outdated script, and it shouldn't break.

Tell me if everything is working as expected.

CodeByFlo commented 3 years ago

Hi @konsalex, thanks a lot, it works!